Skip to content

Commit dcccbc6

Browse files
authored
#2080. Add correct member overrides tests. Part 2. Setters (#2093)
1 parent e4cc8f8 commit dcccbc6

11 files changed

+407
-1
lines changed

Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t06.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class C2 implements I1, I2, I3 {
4747
// [cfe] unspecified
4848

4949
void m2(int v1, {String s0 = ""}) {}
50-
// ^
50+
// ^^
5151
// [analyzer] unspecified
5252
// [cfe] unspecified
5353
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is a compile-time error if `m` and `m′` are both
14+
/// setters and function type `m` is not a subtype of `m′`. Test `implements`
15+
/// clause
16+
/// @author [email protected]
17+
18+
interface class I {
19+
void set m(num n) {}
20+
}
21+
22+
class C implements I {
23+
void set m(int i) {}
24+
// ^
25+
// [analyzer] unspecified
26+
// [cfe] unspecified
27+
}
28+
29+
mixin M implements I {
30+
void set m(int i) {}
31+
// ^
32+
// [analyzer] unspecified
33+
// [cfe] unspecified
34+
}
35+
36+
main() {
37+
print(C);
38+
print(M);
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is a compile-time error if `m` and `m′` are both
14+
/// setters and function type `m` is not a subtype of `m′`. Test `implements`
15+
/// clause
16+
/// @author [email protected]
17+
18+
interface class I1 {
19+
void set m(int i) {}
20+
}
21+
22+
interface class I2 {
23+
void set m(Object i) {}
24+
}
25+
26+
class C implements I1, I2 {
27+
void set m(num i) {}
28+
// ^
29+
// [analyzer] unspecified
30+
// [cfe] unspecified
31+
}
32+
33+
mixin M implements I1, I2 {
34+
void set m(num i) {}
35+
// ^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
}
39+
40+
main() {
41+
print(C);
42+
print(M);
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is not an error if `m` and `m′` are both setters
14+
/// and function type `m` is a subtype of `m′. Test `implements` clause
15+
/// @author [email protected]
16+
17+
interface class I {
18+
void set m1(num v1) {}
19+
void set m2(covariant int v1) {}
20+
}
21+
22+
class C implements I {
23+
void set m1(covariant int i) {}
24+
void set m2(num i) {}
25+
}
26+
27+
mixin M implements I {
28+
void set m1(covariant int i) {}
29+
void set m2(num i) {}
30+
}
31+
32+
main() {
33+
print(C);
34+
print(M);
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is not an error if `m` and `m′` are both setters
14+
/// and function type `m` is a subtype of `m′. Test `implements` clause
15+
/// @author [email protected]
16+
17+
interface class I1 {
18+
void set m(num v1) {}
19+
}
20+
21+
interface class I2 {
22+
void set m(covariant int v1) {}
23+
}
24+
25+
class C implements I1, I2 {
26+
void set m(covariant int i) {}
27+
}
28+
29+
mixin M implements I1, I2 {
30+
void set m(num i) {}
31+
}
32+
33+
main() {
34+
print(C);
35+
print(M);
36+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is a compile-time error if `m` and `m′` are both
14+
/// setters and function type `m` is not a subtype of `m′. Test `implements`
15+
/// clause
16+
/// @author [email protected]
17+
18+
interface class I {
19+
void set m1(num v1) {}
20+
void set m2(covariant int v1) {}
21+
}
22+
23+
class C implements I {
24+
void set m1(covariant String i) {}
25+
// ^^
26+
// [analyzer] unspecified
27+
// [cfe] unspecified
28+
29+
void set m2(String i) {}
30+
// ^^
31+
// [analyzer] unspecified
32+
// [cfe] unspecified
33+
}
34+
35+
mixin M implements I {
36+
void set m1(covariant String i) {}
37+
// ^^
38+
// [analyzer] unspecified
39+
// [cfe] unspecified
40+
41+
void set m2(String i) {}
42+
// ^^
43+
// [analyzer] unspecified
44+
// [cfe] unspecified
45+
}
46+
47+
main() {
48+
print(C);
49+
print(M);
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is a compile-time error if `m` and `m′` are both
14+
/// setters and function type `m` is not a subtype of `m′`. Test `extends` and
15+
/// `on` clauses
16+
/// @author [email protected]
17+
18+
interface class I {
19+
void set m(num n) {}
20+
}
21+
22+
class C extends I {
23+
void set m(int i) {}
24+
// ^
25+
// [analyzer] unspecified
26+
// [cfe] unspecified
27+
}
28+
29+
mixin M on I {
30+
void set m(int i) {}
31+
// ^
32+
// [analyzer] unspecified
33+
// [cfe] unspecified
34+
}
35+
36+
main() {
37+
print(C);
38+
print(M);
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is a compile-time error if `m` and `m′` are both
14+
/// setters and function type `m` is not a subtype of `m′`. Test `extends` and
15+
/// `on` clauses
16+
/// @author [email protected]
17+
18+
interface class I1 {
19+
void set m(int i) {}
20+
}
21+
22+
interface class I2 {
23+
void set m(Object i) {}
24+
}
25+
26+
class C extends I1 implements I2 {
27+
void set m(num i) {}
28+
// ^
29+
// [analyzer] unspecified
30+
// [cfe] unspecified
31+
}
32+
33+
mixin M on I2 implements I1 {
34+
void set m(num i) {}
35+
// ^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
}
39+
40+
main() {
41+
print(C);
42+
print(M);
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is not an error if `m` and `m′` are both setters
14+
/// and function type `m` is a subtype of `m′. Test `extends` and `on` clauses
15+
/// @author [email protected]
16+
17+
interface class I {
18+
void set m1(num v1) {}
19+
void set m2(covariant int v1) {}
20+
}
21+
22+
class C extends I {
23+
void set m1(covariant int i) {}
24+
void set m2(num i) {}
25+
}
26+
27+
mixin M on I {
28+
void set m1(covariant int i) {}
29+
void set m2(num i) {}
30+
}
31+
32+
main() {
33+
print(C);
34+
print(M);
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Let m and m′ be member signatures with the same name id. Then m
6+
/// is a correct override of m′ iff the following criteria are all satisfied:
7+
/// ...
8+
/// • If m and m′ are both methods or both setters: Let F be the function type
9+
/// of m except that the parameter type is the built-in class Object for each
10+
/// parameter of m which is covariant-by-declaration. Let F′ be the function
11+
/// type of m′. F must then be a subtype of F′.
12+
///
13+
/// @description Checks that it is not an error if `m` and `m′` are both setters
14+
/// and function type `m` is a subtype of `m′. Test `extends` and `on` clauses
15+
/// @author [email protected]
16+
17+
interface class I1 {
18+
void set m(num v1) {}
19+
}
20+
21+
interface class I2 {
22+
void set m(covariant int v1) {}
23+
}
24+
25+
class C extends I1 implements I2 {
26+
void set m(covariant int i) {}
27+
}
28+
29+
mixin M on I2 implements I1 {
30+
void set m(num i) {}
31+
}
32+
33+
main() {
34+
print(C);
35+
print(M);
36+
}

0 commit comments

Comments
 (0)