Skip to content

Commit 58453dc

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Use findMethod() and assertElement() in ExtensionMethodTest.
[email protected], [email protected] Change-Id: I25d8a7021e78d045bd57b7462fe24c14d8cab518 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110138 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 94b34b2 commit 58453dc

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

pkg/analyzer/test/src/dart/resolution/extension_method_test.dart

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analyzer/dart/analysis/features.dart';
66
import 'package:analyzer/src/error/codes.dart';
77
import 'package:analyzer/src/generated/engine.dart';
8-
import 'package:test/test.dart';
98
import 'package:test_reflective_loader/test_reflective_loader.dart';
109

1110
import 'driver_resolution.dart';
@@ -57,7 +56,7 @@ f() {
5756
''');
5857

5958
var invocation = findNode.methodInvocation('c.a()');
60-
expect(invocation.methodName.staticElement.library.isDartCore, isFalse);
59+
assertElement(invocation, findElement.method('a', of: 'Core2_Ext'));
6160
}
6261

6362
test_method_noMatch() async {
@@ -111,8 +110,7 @@ f() {
111110
''');
112111

113112
var invocation = findNode.methodInvocation('b.a()');
114-
var declaration = findNode.methodDeclaration('void a()');
115-
expect(invocation.methodName.staticElement, declaration.declaredElement);
113+
assertElement(invocation, findElement.method('a'));
116114
}
117115

118116
test_method_privateExtension() async {
@@ -161,7 +159,7 @@ extension A_Ext on A {
161159
}
162160
163161
extension B_Ext on B {
164-
void /*2*/ a() { }
162+
void a() { }
165163
}
166164
167165
f() {
@@ -171,8 +169,7 @@ f() {
171169
''');
172170

173171
var invocation = findNode.methodInvocation('b.a()');
174-
var declaration = findNode.methodDeclaration('void /*2*/ a()');
175-
expect(invocation.methodName.staticElement, declaration.declaredElement);
172+
assertElement(invocation, findElement.method('a', of: 'B_Ext'));
176173
}
177174

178175
@failingTest
@@ -189,7 +186,7 @@ extension A_Ext<T> on A<T> {
189186
}
190187
191188
extension B_Ext<T> on B<T> {
192-
void /*2*/ f(T x) { }
189+
void f(T x) { }
193190
}
194191
195192
main() {
@@ -200,8 +197,7 @@ main() {
200197
''');
201198

202199
var invocation = findNode.methodInvocation('x.f(o)');
203-
var declaration = findNode.methodDeclaration('void /*2*/ f(T x)');
204-
expect(invocation.methodName.staticElement, declaration.declaredElement);
200+
assertElement(invocation, findElement.method('f', of: 'B_Ext'));
205201
}
206202

207203
test_method_specificSubtypeMatchPlatform() async {
@@ -221,7 +217,7 @@ extension Core_Ext on Core {
221217
}
222218
223219
extension Core2_Ext on Core2 {
224-
void /*2*/ a() => 0;
220+
void a() => 0;
225221
}
226222
227223
f() {
@@ -231,8 +227,7 @@ f() {
231227
''');
232228

233229
var invocation = findNode.methodInvocation('c.a()');
234-
var declaration = findNode.methodDeclaration('void /*2*/ a()');
235-
expect(invocation.methodName.staticElement, declaration.declaredElement);
230+
assertElement(invocation, findElement.method('a', of: 'Core2_Ext'));
236231
}
237232

238233
test_method_unnamedExtension() async {

0 commit comments

Comments
 (0)