@@ -23,8 +23,21 @@ class ExtensionMethodTest extends DriverResolutionTest {
2323 ..contextFeatures = new FeatureSet .forTesting (
2424 sdkVersion: '2.3.0' , additionalFeatures: [Feature .extension_methods]);
2525
26+ test_accessStaticWithinInstance () async {
27+ await assertNoErrorsInCode ('''
28+ class A {}
29+ extension E on A {
30+ static void a() {}
31+ void b() { a(); }
32+ }
33+ ''' );
34+ var invocation = findNode.methodInvocation ('a();' );
35+ assertElement (invocation, findElement.method ('a' ));
36+ assertInvokeType (invocation, 'void Function()' );
37+ }
38+
2639 test_getter_noMatch () async {
27- await assertErrorCodesInCode (r'''
40+ await assertErrorsInCode (r'''
2841class B { }
2942
3043extension A on B { }
3346 B b = B();
3447 int x = b.a;
3548}
36- ''' , [StaticTypeWarningCode .UNDEFINED_GETTER ]);
49+ ''' , [
50+ error (HintCode .UNUSED_LOCAL_VARIABLE , 60 , 1 ),
51+ error (StaticTypeWarningCode .UNDEFINED_GETTER , 66 , 1 ),
52+ ]);
3753 }
3854
3955 test_getter_oneMatch () async {
7894 expect (invocation.identifier.staticElement, declaration.declaredElement);
7995 }
8096
81- test_accessStaticWithinInstance () async {
82- await assertNoErrorsInCode ('''
83- class A {}
84- extension E on A {
85- static void a() {}
86- void b() { a(); }
87- }
88- ''' );
89- var invocation = findNode.methodInvocation ('a();' );
90- assertElement (invocation, findElement.method ('a' ));
91- }
92-
9397 test_method_moreSpecificThanPlatform () async {
9498 //
9599 // An extension with on type clause T1 is more specific than another
@@ -125,6 +129,7 @@ f() {
125129
126130 var invocation = findNode.methodInvocation ('c.a()' );
127131 assertElement (invocation, findElement.method ('a' , of: 'Core2_Ext' ));
132+ assertInvokeType (invocation, 'void Function()' );
128133 }
129134
130135 test_method_noMatch () async {
@@ -181,6 +186,7 @@ f() {
181186
182187 var invocation = findNode.methodInvocation ('b.a()' );
183188 assertElement (invocation, findElement.method ('a' ));
189+ assertInvokeType (invocation, 'void Function()' );
184190 }
185191
186192 test_method_privateExtension () async {
@@ -242,6 +248,7 @@ f() {
242248
243249 var invocation = findNode.methodInvocation ('b.a()' );
244250 assertElement (invocation, findElement.method ('a' , of: 'B_Ext' ));
251+ assertInvokeType (invocation, 'void Function()' );
245252 }
246253
247254 @failingTest
@@ -270,6 +277,7 @@ main() {
270277
271278 var invocation = findNode.methodInvocation ('x.f(o)' );
272279 assertElement (invocation, findElement.method ('f' , of: 'B_Ext' ));
280+ assertInvokeType (invocation, 'void Function(T)' );
273281 }
274282
275283 test_method_specificSubtypeMatchPlatform () async {
@@ -300,6 +308,7 @@ f() {
300308
301309 var invocation = findNode.methodInvocation ('c.a()' );
302310 assertElement (invocation, findElement.method ('a' , of: 'Core2_Ext' ));
311+ assertInvokeType (invocation, 'void Function()' );
303312 }
304313
305314 test_method_unnamedExtension () async {
@@ -331,7 +340,7 @@ extension E2 on A {}
331340 }
332341
333342 test_setter_noMatch () async {
334- await assertErrorCodesInCode (r'''
343+ await assertErrorsInCode (r'''
335344class B { }
336345
337346extension A on B {
@@ -341,7 +350,9 @@ f() {
341350 B b = B();
342351 b.a = 1;
343352}
344- ''' , [StaticTypeWarningCode .UNDEFINED_SETTER ]);
353+ ''' , [
354+ error (StaticTypeWarningCode .UNDEFINED_SETTER , 58 , 1 ),
355+ ]);
345356 }
346357
347358 test_setter_oneMatch () async {
0 commit comments