@@ -43,61 +43,6 @@ void f(int value) {
4343}
4444
4545mixin 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-
10146 test_annotation_references_static_method_in_class () async {
10247 await assertErrorsInCode ('''
10348@Annotation(foo)
@@ -114,18 +59,19 @@ class Annotation {
11459 }
11560
11661 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 ('''
12265class C<@Annotation(foo) T> {
12366 static void foo() {}
12467}
12568class Annotation {
12669 const Annotation(dynamic d);
12770}
128- ''' );
71+ ''' , [
72+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 20 , 3 ),
73+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 20 , 3 ),
74+ ]);
12975 }
13076
13177 test_annotation_references_static_method_in_extension () async {
@@ -144,18 +90,19 @@ class Annotation {
14490 }
14591
14692 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 ('''
15296extension E<@Annotation(foo) T> on T {
15397 static void foo() {}
15498}
15599class Annotation {
156100 const Annotation(dynamic d);
157101}
158- ''' );
102+ ''' , [
103+ error (CompileTimeErrorCode .CONST_WITH_NON_CONSTANT_ARGUMENT , 24 , 3 ),
104+ error (CompileTimeErrorCode .UNDEFINED_IDENTIFIER , 24 , 3 ),
105+ ]);
159106 }
160107
161108 test_annotation_references_static_method_in_mixin () async {
@@ -174,18 +121,80 @@ class Annotation {
174121 }
175122
176123 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 ('''
182127mixin M<@Annotation(foo) T> {
183128 static void foo() {}
184129}
185130class Annotation {
186131 const Annotation(dynamic d);
187132}
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+ ]);
189198 }
190199
191200 @failingTest
0 commit comments