Elements. Fixes after https://dart-review.googlesource.com/c/sdk/+/405660
Bug: https://buganizer.corp.google.com/issues/392069763 Change-Id: Iecbfc55433890c4e5e606dc9b1f2bc005b9b6684 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405800 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
0d90ccc2ec
commit
668754285b
@@ -1397,7 +1397,7 @@ class Name {
|
||||
}
|
||||
|
||||
if (name.startsWith('_')) {
|
||||
var libraryUri = element.firstFragment.libraryFragment!.source.uri;
|
||||
var libraryUri = element.library2!.uri;
|
||||
return Name(libraryUri, name);
|
||||
} else {
|
||||
return Name(null, name);
|
||||
|
||||
@@ -91,12 +91,13 @@ class ExtensionMemberResolver {
|
||||
/// returns [ExtensionResolutionError.ambiguous].
|
||||
ExtensionResolutionResult findExtension(
|
||||
TypeImpl type, SyntacticEntity nameEntity, Name name) {
|
||||
var aaa = _resolver.libraryFragment.accessibleExtensions2;
|
||||
var bbb = aaa.havingMemberWithBaseName(name).toList();
|
||||
var extensions = bbb.applicableTo(
|
||||
targetLibrary: _resolver.definingLibrary,
|
||||
targetType: type,
|
||||
);
|
||||
var extensions = _resolver.libraryFragment.accessibleExtensions2
|
||||
.havingMemberWithBaseName(name)
|
||||
.toList()
|
||||
.applicableTo(
|
||||
targetLibrary: _resolver.definingLibrary,
|
||||
targetType: type,
|
||||
);
|
||||
|
||||
if (extensions.isEmpty) {
|
||||
return ExtensionResolutionError.none;
|
||||
|
||||
@@ -1653,6 +1653,73 @@ MethodInvocation
|
||||
''');
|
||||
}
|
||||
|
||||
test_instance_method_fromInstance_privateName() async {
|
||||
await assertNoErrorsInCode('''
|
||||
extension E on int {
|
||||
void _foo() {}
|
||||
}
|
||||
|
||||
void f() {
|
||||
0._foo();
|
||||
}
|
||||
''');
|
||||
var invocation = findNode.methodInvocation('_foo();');
|
||||
assertResolvedNodeText(invocation, r'''
|
||||
MethodInvocation
|
||||
target: IntegerLiteral
|
||||
literal: 0
|
||||
staticType: int
|
||||
operator: .
|
||||
methodName: SimpleIdentifier
|
||||
token: _foo
|
||||
staticElement: <testLibraryFragment>::@extension::E::@method::_foo
|
||||
element: <testLibraryFragment>::@extension::E::@method::_foo#element
|
||||
staticType: void Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticInvokeType: void Function()
|
||||
staticType: void
|
||||
''');
|
||||
}
|
||||
|
||||
test_instance_method_fromInstance_privateName_inPart() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part of 'test.dart';
|
||||
|
||||
extension E on int {
|
||||
void _foo() {}
|
||||
}
|
||||
''');
|
||||
|
||||
await assertNoErrorsInCode('''
|
||||
part 'a.dart';
|
||||
|
||||
void f() {
|
||||
0._foo();
|
||||
}
|
||||
''');
|
||||
|
||||
var invocation = findNode.methodInvocation('_foo();');
|
||||
assertResolvedNodeText(invocation, r'''
|
||||
MethodInvocation
|
||||
target: IntegerLiteral
|
||||
literal: 0
|
||||
staticType: int
|
||||
operator: .
|
||||
methodName: SimpleIdentifier
|
||||
token: _foo
|
||||
staticElement: <testLibrary>::@fragment::package:test/a.dart::@extension::E::@method::_foo
|
||||
element: <testLibrary>::@fragment::package:test/a.dart::@extension::E::@method::_foo#element
|
||||
staticType: void Function()
|
||||
argumentList: ArgumentList
|
||||
leftParenthesis: (
|
||||
rightParenthesis: )
|
||||
staticInvokeType: void Function()
|
||||
staticType: void
|
||||
''');
|
||||
}
|
||||
|
||||
test_instance_method_specificSubtypeMatchLocal() async {
|
||||
await assertNoErrorsInCode('''
|
||||
class A {}
|
||||
|
||||
Reference in New Issue
Block a user