analyzer: tearoff function reference w/ type args as part of method call

Fixes https://github.com/dart-lang/sdk/issues/47005

Change-Id: I0ea2dcd337030ef471123fd0e02b4398e1ace671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211463
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins 2021-08-26 20:48:15 +00:00 committed by commit-bot@chromium.org
parent 88cd302eb0
commit 59216c7949
2 changed files with 17 additions and 1 deletions

View file

@ -45,7 +45,7 @@ class AstRewriter {
var typeName = node.constructorName.type.name;
if (typeName is SimpleIdentifier) {
var element = nameScope.lookup(typeName.name).getter;
if (element is MethodElement) {
if (element is FunctionElement || element is MethodElement) {
return _toMethodInvocationOfFunctionReference(
node: node, function: typeName);
}

View file

@ -867,6 +867,22 @@ bar() {
findNode.functionReference('foo<int>;'), null, 'dynamic');
}
test_topLevelFunction_targetOfFunctionCall() async {
await assertNoErrorsInCode('''
void foo<T>(T arg) {}
extension on Function {
void m() {}
}
void bar() {
foo<int>.m();
}
''');
assertFunctionReference(findNode.functionReference('foo<int>'),
findElement.topFunction('foo'), 'void Function(int)');
}
test_topLevelVariable_prefix_unknownIdentifier() async {
newFile('$testPackageLibPath/a.dart', content: '');
await assertErrorsInCode('''