|
6 | 6 | /// invocation with corresponding member basename m and target expression `e`,
|
7 | 7 | /// where `e` has static type `S`, if
|
8 | 8 | /// ...
|
9 |
| -/// - The type S does not have a member with the basename m. For this, the type |
10 |
| -/// `dynamic` is considered as having all member names, and an expression of |
11 |
| -/// type `Never` or `void` cannot occur as the target of a member invocation, |
12 |
| -/// so none of these can ever have applicable extensions. Function types and |
13 |
| -/// the type `Function` are considered as having a `call` member. This ensure |
14 |
| -/// that if there is an applicable extension, the existing invocation would |
15 |
| -/// otherwise be a compile-time error. Members of `Object` exists on all |
16 |
| -/// types, so they can never be the target of implicit member invocations |
17 |
| -/// (they can also not be declared as extension members). |
| 9 | +/// - The type S does not have an instance member with the basename m. For this, |
| 10 | +/// the type `dynamic` is considered as having all member names, and an |
| 11 | +/// expression of type `Never` or `void` cannot occur as the target of a |
| 12 | +/// member invocation, so none of these can ever have applicable extensions. |
| 13 | +/// Function types and the type `Function` are considered as having a `call` |
| 14 | +/// member. This ensure that if there is an applicable extension, the existing |
| 15 | +/// invocation would otherwise be a compile-time error. Members of `Object` |
| 16 | +/// exists on all types, so they can never be the target of implicit member |
| 17 | +/// invocations (they can also not be declared as extension members). |
18 | 18 | ///
|
19 |
| -/// @description Check that an extension member with the basename `m` is not |
20 |
| -/// applicable if on type has a static member with the same basename. |
| 19 | +/// @description Check that an extension member with the basename `m` is |
| 20 | +/// applicable even if the on type has a static member with the same basename. |
21 | 21 |
|
22 | 22 |
|
| 23 | +import '../../Utils/expect.dart'; |
| 24 | + |
| 25 | +String _log = ""; |
| 26 | + |
23 | 27 | class C {
|
24 | 28 | static String get m1 => "m1";
|
25 | 29 | static String m2() => "m2";
|
26 |
| - static void set m3(String _) {} |
| 30 | + static void set m3(String _) { |
| 31 | + _log = "m3"; |
| 32 | + } |
| 33 | + static void set m4(String _) { |
| 34 | + _log = "m4"; |
| 35 | + } |
27 | 36 | }
|
28 | 37 |
|
29 | 38 | extension Ext on C {
|
30 |
| - void set m1(String _) {} |
31 |
| - void set m2(String _) {} |
32 |
| - String m3() => "Ext.m2"; |
| 39 | + void set m1(String _) { |
| 40 | + _log = "Ext.m1"; |
| 41 | + } |
| 42 | + void set m2(String _) { |
| 43 | + _log = "Ext.m2"; |
| 44 | + } |
| 45 | + String m3() => "Ext.m3"; |
| 46 | + String get m4 => "Ext.m4"; |
33 | 47 | }
|
34 | 48 |
|
35 | 49 | main() {
|
36 |
| - print(C().m1); |
37 |
| -// ^^ |
38 |
| -// [analyzer] unspecified |
39 |
| -// [cfe] unspecified |
40 |
| - |
41 |
| - print(C().m2()); |
42 |
| -// ^^ |
43 |
| -// [analyzer] unspecified |
44 |
| -// [cfe] unspecified |
45 |
| - |
46 |
| - C().m3 = ""; |
47 |
| -// ^^ |
48 |
| -// [analyzer] unspecified |
49 |
| -// [cfe] unspecified |
| 50 | + C().m1 = ""; |
| 51 | + Expect.equals("Ext.m1", _log); |
| 52 | + C().m2 = ""; |
| 53 | + Expect.equals("Ext.m2", _log); |
| 54 | + Expect.equals("Ext.m3", C().m3()); |
| 55 | + Expect.equals("Ext.m4", C().m4); |
50 | 56 | }
|
0 commit comments