@@ -10,77 +10,63 @@ import '../dart/resolution/context_collection_resolution.dart';
10
10
main () {
11
11
defineReflectiveSuite (() {
12
12
defineReflectiveTests (ImplicitThisReferenceInInitializerTest );
13
- defineReflectiveTests (
14
- ImplicitThisReferenceInInitializerWithoutNullSafetyTest );
15
13
});
16
14
}
17
15
18
16
@reflectiveTest
19
- class ImplicitThisReferenceInInitializerTest extends PubPackageResolutionTest
20
- with ImplicitThisReferenceInInitializerTestCases {
21
- test_class_field_late_invokeInstanceMethod () async {
17
+ class ImplicitThisReferenceInInitializerTest extends PubPackageResolutionTest {
18
+ test_class_fieldInitializer_commentReference_prefixedIdentifier () async {
22
19
await assertNoErrorsInCode (r'''
23
20
class A {
24
- late int x = foo();
25
- int foo() => 0;
26
- }
27
- ''' );
28
- }
29
-
30
- test_class_field_late_invokeStaticMethod () async {
31
- await assertNoErrorsInCode (r'''
32
- class A {
33
- late int x = foo();
34
- static int foo() => 0;
21
+ int a = 0;
22
+ /// foo [a.isEven] bar
23
+ int x = 1;
35
24
}
36
25
''' );
37
26
}
38
27
39
- test_class_field_late_readInstanceField () async {
28
+ test_class_fieldInitializer_commentReference_simpleIdentifier () async {
40
29
await assertNoErrorsInCode (r'''
41
30
class A {
42
31
int a = 0;
43
- late int x = a;
32
+ /// foo [a] bar
33
+ int x = 1;
44
34
}
45
35
''' );
46
36
}
47
37
48
- test_class_field_late_readStaticField () async {
38
+ test_class_fieldInitializer_late_invokeInstanceMethod () async {
49
39
await assertNoErrorsInCode (r'''
50
40
class A {
51
- static int a = 0 ;
52
- late int x = a ;
41
+ late int x = foo() ;
42
+ int foo() => 0 ;
53
43
}
54
44
''' );
55
45
}
56
46
57
- test_mixin_field_late_readInstanceField () async {
47
+ test_class_fieldInitializer_late_invokeStaticMethod () async {
58
48
await assertNoErrorsInCode (r'''
59
- mixin M {
60
- int a = 0 ;
61
- late int x = a ;
49
+ class A {
50
+ late int x = foo() ;
51
+ static int foo() => 0 ;
62
52
}
63
53
''' );
64
54
}
65
- }
66
55
67
- mixin ImplicitThisReferenceInInitializerTestCases on PubPackageResolutionTest {
68
- test_class_field_commentReference_prefixedIdentifier () async {
56
+ test_class_fieldInitializer_late_readInstanceField () async {
69
57
await assertNoErrorsInCode (r'''
70
58
class A {
71
59
int a = 0;
72
- /// foo [a.isEven] bar
73
- int x = 1;
60
+ late int x = a;
74
61
}
75
62
''' );
76
63
}
77
64
78
- test_class_field_commentReference_simpleIdentifier () async {
65
+ test_class_fieldInitializer_late_readStaticField () async {
79
66
await assertNoErrorsInCode (r'''
80
67
class A {
81
- int a = 0;
82
- /// foo [a] bar
83
- int x = 1;
68
+ static int a = 0;
69
+ late int x = a;
84
70
}
85
71
''' );
86
72
}
@@ -134,7 +120,7 @@ class B {
134
120
''' );
135
121
}
136
122
137
- test_field2 () async {
123
+ test_fieldInitializer () async {
138
124
await assertErrorsInCode (r'''
139
125
class A {
140
126
final x = 0;
@@ -145,7 +131,18 @@ class A {
145
131
]);
146
132
}
147
133
148
- test_instanceVariableInitializer_nestedLocal () async {
134
+ test_fieldInitializer_functionReference () async {
135
+ await assertErrorsInCode (r'''
136
+ class A {
137
+ void x<T>() {}
138
+ final y = x<int>;
139
+ }
140
+ ''' , [
141
+ error (CompileTimeErrorCode .IMPLICIT_THIS_REFERENCE_IN_INITIALIZER , 39 , 1 ),
142
+ ]);
143
+ }
144
+
145
+ test_fieldInitializer_nestedLocal () async {
149
146
// Test that (1) does not prevent reporting an error at (2).
150
147
await assertErrorsInCode (r'''
151
148
class A {
@@ -187,6 +184,15 @@ class A {
187
184
]);
188
185
}
189
186
187
+ test_mixin_field_late_readInstanceField () async {
188
+ await assertNoErrorsInCode (r'''
189
+ mixin M {
190
+ int a = 0;
191
+ late int x = a;
192
+ }
193
+ ''' );
194
+ }
195
+
190
196
test_prefixedIdentifier () async {
191
197
await assertNoErrorsInCode (r'''
192
198
class A {
@@ -318,8 +324,3 @@ class A<T> {
318
324
''' );
319
325
}
320
326
}
321
-
322
- @reflectiveTest
323
- class ImplicitThisReferenceInInitializerWithoutNullSafetyTest
324
- extends PubPackageResolutionTest
325
- with ImplicitThisReferenceInInitializerTestCases , WithoutNullSafetyMixin {}
0 commit comments