Issue 46103. Resolve type arguments of TypeName(s) - there might be expressions.

Bug: https://github.com/dart-lang/sdk/issues/46103
Change-Id: Ia847403c7609f289f3f3f8bd5cd10e221216993f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-09-21 17:23:18 +00:00 committed by commit-bot@chromium.org
parent bcaa2a320c
commit dc5eec2c5a
2 changed files with 27 additions and 1 deletions

View file

@ -3052,7 +3052,12 @@ class ScopeResolverVisitor extends ResolverBase {
}
@override
void visitTypeName(TypeName node) {}
void visitTypeName(TypeName node) {
// All TypeName(s) are already resolved, so we don't resolve it here.
// But there might be type arguments with Expression(s), such as
// annotations on formal parameters of GenericFunctionType(s).
node.typeArguments?.accept(this);
}
@override
void visitVariableDeclaration(VariableDeclaration node) {

View file

@ -27,6 +27,27 @@ class MetadataResolutionTest extends PubPackageResolutionTest {
return findElement.importFind('package:test/a.dart');
}
test_at_genericFunctionType_formalParameter() async {
await assertNoErrorsInCode(r'''
const a = 42;
List<void Function(@a int b)> f() => [];
''');
var annotation = findNode.annotation('@a');
_assertResolvedNodeText(annotation, r'''
Annotation
atSign: @
element: self::@getter::a
name: SimpleIdentifier
staticElement: self::@getter::a
staticType: null
token: a
''');
_assertAnnotationValueText(annotation, '''
int 42
''');
}
test_location_partDirective() async {
newFile('$testPackageLibPath/a.dart', content: r'''
part of 'test.dart';