@@ -43,61 +43,6 @@ void f(int value) {
43
43
}
44
44
45
45
mixin UndefinedIdentifierTestCases on PubPackageResolutionTest {
46
- test_annotation_favors_scope_resolution_over_this_resolution_class () async {
47
- // If an annotation on a class type parameter cannot be resolved using the
48
- // normal scope resolution mechanism, it is resolved via implicit `this`.
49
- // Note: this behavior doesn't match the spec so we may change it - see
50
- // https://github.com/dart-lang/language/issues/1790
51
- await assertNoErrorsInCode ('''
52
- class C<@Annotation.function(foo) @Annotation.type(B) T> {
53
- static void foo() {}
54
- static void B() {}
55
- }
56
- class B {}
57
- class Annotation {
58
- const Annotation.function(void Function() f);
59
- const Annotation.type(Type t);
60
- }
61
- ''' );
62
- }
63
-
64
- test_annotation_favors_scope_resolution_over_this_resolution_extension () async {
65
- // If an annotation on an extension type parameter cannot be resolved using
66
- // the normal scope resolution mechanism, it is resolved via implicit
67
- // `this`. Note: this behavior doesn't match the spec so we may change it -
68
- // see https://github.com/dart-lang/language/issues/1790
69
- await assertNoErrorsInCode ('''
70
- extension E<@Annotation.function(foo) @Annotation.type(B) T> on C {}
71
- class C {
72
- static void foo() {}
73
- static void B() {}
74
- }
75
- class B {}
76
- class Annotation {
77
- const Annotation.function(void Function() f);
78
- const Annotation.type(Type t);
79
- }
80
- ''' );
81
- }
82
-
83
- test_annotation_favors_scope_resolution_over_this_resolution_mixin () async {
84
- // If an annotation on a mixin type parameter cannot be resolved using the
85
- // normal scope resolution mechanism, it is resolved via implicit `this`.
86
- // Note: this behavior doesn't match the spec so we may change it - see
87
- // https://github.com/dart-lang/language/issues/1790
88
- await assertNoErrorsInCode ('''
89
- mixin M<@Annotation.function(foo) @Annotation.type(B) T> {
90
- static void foo() {}
91
- static void B() {}
92
- }
93
- class B {}
94
- class Annotation {
95
- const Annotation.function(void Function() f);
96
- const Annotation.type(Type t);
97
- }
98
- ''' );
99
- }
100
-
101
46
test_annotation_references_static_method_in_class () async {
102
47
await assertErrorsInCode ('''
103
48
@Annotation(foo)
@@ -114,18 +59,19 @@ class Annotation {
114
59
}
115
60
116
61
test_annotation_references_static_method_in_class_from_type_parameter () async {
117
- // It is allowed for an annotation of a class type parameter to refer to
118
- // a method in a class (note: this doesn't match the spec but we currently
119
- // test it to make sure we match CFE behavior - see
120
- // https://github.com/dart-lang/language/issues/1790)
121
- await assertNoErrorsInCode ('''
62
+ // It not is allowed for an annotation of a class type parameter to refer to
63
+ // a method in a class.
64
+ await assertErrorsInCode ('''
122
65
class C<@Annotation(foo) T> {
123
66
static void foo() {}
124
67
}
125
68
class Annotation {
126
69
const Annotation(dynamic d);
127
70
}
128
- ''' );
71
+ ''' , [
72
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 20 , 3 ),
73
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 20 , 3 ),
74
+ ]);
129
75
}
130
76
131
77
test_annotation_references_static_method_in_extension () async {
@@ -144,18 +90,19 @@ class Annotation {
144
90
}
145
91
146
92
test_annotation_references_static_method_in_extension_from_type_parameter () async {
147
- // It is allowed for an annotation of a mixin type parameter to refer to
148
- // a method in a class (note: this doesn't match the spec but we currently
149
- // test it to make sure we match CFE behavior - see
150
- // https://github.com/dart-lang/language/issues/1790)
151
- await assertNoErrorsInCode ('''
93
+ // It is not allowed for an annotation of an extension type parameter to
94
+ // refer to a method in a class.
95
+ await assertErrorsInCode ('''
152
96
extension E<@Annotation(foo) T> on T {
153
97
static void foo() {}
154
98
}
155
99
class Annotation {
156
100
const Annotation(dynamic d);
157
101
}
158
- ''' );
102
+ ''' , [
103
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 24 , 3 ),
104
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 24 , 3 ),
105
+ ]);
159
106
}
160
107
161
108
test_annotation_references_static_method_in_mixin () async {
@@ -174,18 +121,80 @@ class Annotation {
174
121
}
175
122
176
123
test_annotation_references_static_method_in_mixin_from_type_parameter () async {
177
- // It is allowed for an annotation of a mixin type parameter to refer to
178
- // a method in a class (note: this doesn't match the spec but we currently
179
- // test it to make sure we match CFE behavior - see
180
- // https://github.com/dart-lang/language/issues/1790)
181
- await assertNoErrorsInCode ('''
124
+ // It is not allowed for an annotation of a mixin type parameter to refer to
125
+ // a method in a class.
126
+ await assertErrorsInCode ('''
182
127
mixin M<@Annotation(foo) T> {
183
128
static void foo() {}
184
129
}
185
130
class Annotation {
186
131
const Annotation(dynamic d);
187
132
}
188
- ''' );
133
+ ''' , [
134
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 20 , 3 ),
135
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 20 , 3 ),
136
+ ]);
137
+ }
138
+
139
+ test_annotation_uses_scope_resolution_class () async {
140
+ // If an annotation on a class type parameter cannot be resolved using the
141
+ // normal scope resolution mechanism, it is not resolved via implicit
142
+ // `this`.
143
+ await assertErrorsInCode ('''
144
+ class C<@Annotation.function(foo) @Annotation.type(B) T> {
145
+ static void foo() {}
146
+ static void B() {}
147
+ }
148
+ class B {}
149
+ class Annotation {
150
+ const Annotation.function(void Function() f);
151
+ const Annotation.type(Type t);
152
+ }
153
+ ''' , [
154
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 29 , 3 ),
155
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 29 , 3 ),
156
+ ]);
157
+ }
158
+
159
+ test_annotation_uses_scope_resolution_extension () async {
160
+ // If an annotation on an extension type parameter cannot be resolved using
161
+ // the normal scope resolution mechanism, it is not resolved via implicit
162
+ // `this`.
163
+ await assertErrorsInCode ('''
164
+ extension E<@Annotation.function(foo) @Annotation.type(B) T> on C {}
165
+ class C {
166
+ static void foo() {}
167
+ static void B() {}
168
+ }
169
+ class B {}
170
+ class Annotation {
171
+ const Annotation.function(void Function() f);
172
+ const Annotation.type(Type t);
173
+ }
174
+ ''' , [
175
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 33 , 3 ),
176
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 33 , 3 ),
177
+ ]);
178
+ }
179
+
180
+ test_annotation_uses_scope_resolution_mixin () async {
181
+ // If an annotation on a mixin type parameter cannot be resolved using the
182
+ // normal scope resolution mechanism, it is not resolved via implicit
183
+ // `this`.
184
+ await assertErrorsInCode ('''
185
+ mixin M<@Annotation.function(foo) @Annotation.type(B) T> {
186
+ static void foo() {}
187
+ static void B() {}
188
+ }
189
+ class B {}
190
+ class Annotation {
191
+ const Annotation.function(void Function() f);
192
+ const Annotation.type(Type t);
193
+ }
194
+ ''' , [
195
+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 29 , 3 ),
196
+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 29 , 3 ),
197
+ ]);
189
198
}
190
199
191
200
@failingTest
0 commit comments