Chromium Code Reviews| 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..8b9dd3d5085d95358e817e00f1df813ef7ace9a6 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,61 @@ 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 { |
| + Node type = pop(); |
|
Paul Berry
2017/02/22 18:47:25
Shouldn't the type of `type` be TypeAnnotation?
floitsch
2017/02/22 19:21:39
Maybe. I wasn't sure.
Changed to TypeAnnotation.
|
| + TypeParameterList templateParameters = pop(); |
| + SimpleIdentifier name = pop(); |
| + List<Annotation> metadata = pop(); |
| + |
|
Paul Berry
2017/02/22 18:47:25
Duplicate lines 1113-1114 here.
floitsch
2017/02/22 19:21:39
Done.
|
| + if (type is! GenericFunctionType) { |
| + // TODO(brianwilkerson) Generate an error and recover (better than |
| + // this). |
| + push(ast.genericTypeAlias( |
| + commentAndMetadata.comment, |
|
Paul Berry
2017/02/22 18:47:26
Change to "comment"
floitsch
2017/02/22 19:21:40
Acknowledged.
|
| + commentAndMetadata.metadata, |
|
Paul Berry
2017/02/22 18:47:25
Change to "metadata"
floitsch
2017/02/22 19:21:39
Acknowledged.
|
| + keyword, |
|
Paul Berry
2017/02/22 18:47:26
Change to "toAnalyzerToken(typedefKeyword)"
floitsch
2017/02/22 19:21:39
Acknowledged.
|
| + name, |
| + typeParameters, |
| + equals, |
|
Paul Berry
2017/02/22 18:47:26
Change to "toAnalyzerToken(equals)"
floitsch
2017/02/22 19:21:39
Acknowledged.
|
| + null, |
| + semicolon)); |
|
Paul Berry
2017/02/22 18:47:26
Change to "toAnalyzerToken(endToken)"
floitsch
2017/02/22 19:21:39
Acknowledged.
|
| + } else { |
| + FunctionTypeAnnotation functionType = type; |
|
Paul Berry
2017/02/22 18:47:26
I'm confused by this. Since the if-test on line 1
floitsch
2017/02/22 19:21:40
Changed the whole thing.
|
| + push(ast.genericTypeAlias( |
| + commentAndMetadata.comment, |
|
Paul Berry
2017/02/22 18:47:25
Change to "comment"
floitsch
2017/02/22 19:21:39
Done.
|
| + commentAndMetadata.metadata, |
|
Paul Berry
2017/02/22 18:47:25
Change to "metadata"
floitsch
2017/02/22 19:21:39
Done.
|
| + keyword, |
|
Paul Berry
2017/02/22 18:47:25
Change to "toAnalyzerToken(typedefKeyword)"
floitsch
2017/02/22 19:21:39
Done.
|
| + name, |
| + typeParameters, |
| + equals, |
|
Paul Berry
2017/02/22 18:47:26
Change to "toAnalyzerToken(equals)"
floitsch
2017/02/22 19:21:39
Done.
|
| + functionType, |
| + semicolon)); |
|
Paul Berry
2017/02/22 18:47:25
Change to "toAnalyzerToken(endToken)"
floitsch
2017/02/22 19:21:39
Done.
|
| + } |
| + } |
| } |
| /** |