Skip to content

Commit 634aa46

Browse files
pqcommit-bot@chromium.org
authored andcommitted
remove extension field checks
follow-up from: https://dart-review.googlesource.com/c/sdk/+/109322/3/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart#241 and some test renames Change-Id: Ia22768ed60cf85a0b3d6244ff044ff31af17aad6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109680 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 760c3a0 commit 634aa46

File tree

2 files changed

+45
-48
lines changed

2 files changed

+45
-48
lines changed

pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ class MethodInvocationResolver {
246246
for (var accessor in extension.accessors) {
247247
checkElement(accessor, extension);
248248
}
249-
for (var field in extension.fields) {
250-
checkElement(field, extension);
251-
}
252249
for (var method in extension.methods) {
253250
checkElement(method, extension);
254251
}

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

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ExtensionMethodTest extends DriverResolutionTest {
2323
..contextFeatures = new FeatureSet.forTesting(
2424
sdkVersion: '2.3.0', additionalFeatures: [Feature.extension_methods]);
2525

26-
test_more_specific_than_platform() async {
26+
test_method_moreSpecificThanPlatform() async {
2727
//
2828
// An extension with on type clause T1 is more specific than another
2929
// extension with on type clause T2 iff
@@ -60,15 +60,7 @@ f() {
6060
expect(invocation.methodName.staticElement.library.isDartCore, isFalse);
6161
}
6262

63-
test_multipleExtensions() async {
64-
await assertNoErrorsInCode('''
65-
class A {}
66-
extension E1 on A {}
67-
extension E2 on A {}
68-
''');
69-
}
70-
71-
test_no_match() async {
63+
test_method_noMatch() async {
7264
await assertErrorCodesInCode(r'''
7365
class B { }
7466
@@ -83,7 +75,7 @@ f() {
8375
''', [StaticTypeWarningCode.UNDEFINED_METHOD]);
8476
}
8577

86-
test_noMostSpecificExtension() async {
78+
test_method_noMostSpecificExtension() async {
8779
await assertErrorsInCode('''
8880
class A { }
8981
@@ -104,7 +96,7 @@ f() {
10496
]);
10597
}
10698

107-
test_one_match() async {
99+
test_method_oneMatch() async {
108100
await assertNoErrorsInCode('''
109101
class B { }
110102
@@ -123,38 +115,7 @@ f() {
123115
expect(invocation.methodName.staticElement, declaration.declaredElement);
124116
}
125117

126-
test_specific_subtype_match_platform() async {
127-
newFile('/test/lib/core.dart', content: '''
128-
library dart.core;
129-
130-
class Core { }
131-
132-
class Core2 extends Core { }
133-
''');
134-
135-
await assertNoErrorsInCode('''
136-
import 'core.dart';
137-
138-
extension Core_Ext on Core {
139-
void a() { }
140-
}
141-
142-
extension Core2_Ext on Core2 {
143-
void /*2*/ a() => 0;
144-
}
145-
146-
f() {
147-
Core2 c = Core2();
148-
c.a();
149-
}
150-
''');
151-
152-
var invocation = findNode.methodInvocation('c.a()');
153-
var declaration = findNode.methodDeclaration('void /*2*/ a()');
154-
expect(invocation.methodName.staticElement, declaration.declaredElement);
155-
}
156-
157-
test_specificSubtype_match_local() async {
118+
test_method_specificSubtypeMatchLocal() async {
158119
await assertNoErrorsInCode('''
159120
class A { }
160121
@@ -180,7 +141,7 @@ f() {
180141
}
181142

182143
@failingTest
183-
test_specificSubtype_match_local_generics() async {
144+
test_method_specificSubtypeMatchLocalGenerics() async {
184145
await assertNoErrorsInCode('''
185146
class A<T> { }
186147
@@ -207,4 +168,43 @@ main() {
207168
var declaration = findNode.methodDeclaration('void /*2*/ f(T x)');
208169
expect(invocation.methodName.staticElement, declaration.declaredElement);
209170
}
171+
172+
test_method_specificSubtypeMatchPlatform() async {
173+
newFile('/test/lib/core.dart', content: '''
174+
library dart.core;
175+
176+
class Core { }
177+
178+
class Core2 extends Core { }
179+
''');
180+
181+
await assertNoErrorsInCode('''
182+
import 'core.dart';
183+
184+
extension Core_Ext on Core {
185+
void a() { }
186+
}
187+
188+
extension Core2_Ext on Core2 {
189+
void /*2*/ a() => 0;
190+
}
191+
192+
f() {
193+
Core2 c = Core2();
194+
c.a();
195+
}
196+
''');
197+
198+
var invocation = findNode.methodInvocation('c.a()');
199+
var declaration = findNode.methodDeclaration('void /*2*/ a()');
200+
expect(invocation.methodName.staticElement, declaration.declaredElement);
201+
}
202+
203+
test_multipleExtensions() async {
204+
await assertNoErrorsInCode('''
205+
class A {}
206+
extension E1 on A {}
207+
extension E2 on A {}
208+
''');
209+
}
210210
}

0 commit comments

Comments
 (0)