Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
index a63af7f9ac69314a36f08e0b54e96eb0793914d4..1331632efd400e7e4ecdd0f9a8e7bfefec5e5b35 100644 |
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart |
@@ -439,7 +439,7 @@ class AstBuilder extends ScopeListener { |
push(ast.symbolLiteral(toAnalyzerToken(hashToken), components)); |
} |
- void endType(Token beginToken, Token endToken) { |
+ void handleType(Token beginToken, Token endToken) { |
debugEvent("Type"); |
TypeArgumentList arguments = pop(); |
Identifier name = pop(); |
@@ -1097,28 +1097,52 @@ class AstBuilder extends ScopeListener { |
// keyword up to an element? |
handleIdentifier(token); |
handleNoTypeArguments(token); |
- endType(token, token); |
+ handleType(token, token); |
} |
@override |
- void endFunctionTypeAlias(Token typedefKeyword, Token endToken) { |
+ void endFunctionTypeAlias( |
+ Token typedefKeyword, Token equals, Token endToken) { |
debugEvent("FunctionTypeAlias"); |
- FormalParameterList parameters = pop(); |
- TypeParameterList typeParameters = pop(); |
- SimpleIdentifier name = pop(); |
- TypeAnnotation returnType = pop(); |
- List<Annotation> metadata = pop(); |
- // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
- Comment comment = null; |
- push(ast.functionTypeAlias( |
- comment, |
- metadata, |
- toAnalyzerToken(typedefKeyword), |
- returnType, |
- name, |
- typeParameters, |
- parameters, |
- toAnalyzerToken(endToken))); |
+ if (equals == null) { |
+ FormalParameterList parameters = pop(); |
+ TypeParameterList typeParameters = pop(); |
+ SimpleIdentifier name = pop(); |
+ TypeAnnotation returnType = pop(); |
+ List<Annotation> metadata = pop(); |
+ // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
+ Comment comment = null; |
+ push(ast.functionTypeAlias( |
+ comment, |
+ metadata, |
+ toAnalyzerToken(typedefKeyword), |
+ returnType, |
+ name, |
+ typeParameters, |
+ parameters, |
+ toAnalyzerToken(endToken))); |
+ } else { |
+ TypeAnnotation type = pop(); |
+ TypeParameterList templateParameters = pop(); |
+ SimpleIdentifier name = pop(); |
+ List<Annotation> metadata = pop(); |
+ // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
+ Comment comment = null; |
+ if (type is! GenericFunctionType) { |
+ // TODO(brianwilkerson) Generate an error and recover (better than |
Paul Berry
2017/02/22 19:28:36
Feel free to assign this TODO to me.
floitsch
2017/02/23 12:15:19
Done.
|
+ // this). |
+ type = null; |
+ } |
+ push(ast.genericTypeAlias( |
+ comment, |
+ metadata, |
+ toAnalyzerToken(typedefKeyword), |
+ name, |
+ templateParameters, |
+ toAnalyzerToken(equals), |
+ type, |
+ toAnalyzerToken(endToken))); |
+ } |
} |
/** |