Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Unified Diff: pkg/analyzer/lib/src/generated/declaration_resolver.dart

Issue 2814223002: Support for generic function as type arguments in DeclarationResolver. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/declaration_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/declaration_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/declaration_resolver.dart b/pkg/analyzer/lib/src/generated/declaration_resolver.dart
index 1b51e8ebd5c3ad1e020c511344f8e70dd49cbc05..9bbba1a5d3a8d518d7b10a84146893b59da5d3b8 100644
--- a/pkg/analyzer/lib/src/generated/declaration_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/declaration_resolver.dart
@@ -279,11 +279,20 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
@override
Object visitGenericFunctionType(GenericFunctionType node) {
- GenericFunctionTypeElement element = node.type.element;
- _setGenericFunctionType(node.returnType, element.returnType);
- _walk(new ElementWalker.forGenericFunctionType(element), () {
- super.visitGenericFunctionType(node);
- });
+ if (_walker.elementBuilder != null) {
+ _walker.elementBuilder.visitGenericFunctionType(node);
+ } else {
+ DartType type = node.type;
+ if (type != null) {
+ Element element = type.element;
+ if (element is GenericFunctionTypeElement) {
+ _setGenericFunctionType(node.returnType, element.returnType);
+ _walk(new ElementWalker.forGenericFunctionType(element), () {
+ super.visitGenericFunctionType(node);
+ });
+ }
+ }
+ }
return null;
}
@@ -546,6 +555,18 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
void _setGenericFunctionType(TypeAnnotation typeNode, DartType type) {
if (typeNode is GenericFunctionTypeImpl) {
typeNode.type = type;
+ } else if (typeNode is NamedType) {
+ typeNode.type = type;
+ if (type is ParameterizedType) {
+ List<TypeAnnotation> nodes =
+ typeNode.typeArguments?.arguments ?? const [];
+ List<DartType> types = type.typeArguments;
+ if (nodes.length == types.length) {
+ for (int i = 0; i < nodes.length; i++) {
+ _setGenericFunctionType(nodes[i], types[i]);
+ }
+ }
+ }
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/declaration_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698