Index: pkg/front_end/lib/src/fasta/source/diet_listener.dart |
diff --git a/pkg/front_end/lib/src/fasta/source/diet_listener.dart b/pkg/front_end/lib/src/fasta/source/diet_listener.dart |
index 08b0fe62c9368ffb3d43bf831078e4f570a5bcb8..506b63e8d7f0fbb084c1125a4df8805fdbd8079b 100644 |
--- a/pkg/front_end/lib/src/fasta/source/diet_listener.dart |
+++ b/pkg/front_end/lib/src/fasta/source/diet_listener.dart |
@@ -4,7 +4,9 @@ |
library fasta.diet_listener; |
-import 'package:kernel/ast.dart' show AsyncMarker, Class, InterfaceType; |
+import 'package:kernel/ast.dart' |
+ show AsyncMarker, Class, InterfaceType, Typedef; |
+import 'package:kernel/ast.dart'; |
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
@@ -195,12 +197,22 @@ class DietListener extends StackListener { |
void endFunctionTypeAlias( |
Token typedefKeyword, Token equals, Token endToken) { |
debugEvent("FunctionTypeAlias"); |
- if (equals != null) { |
- // This is a `typedef NAME = TYPE`. |
- discard(2); // Name and metadata. |
- } else { |
- discard(3); // Name, endToken, and metadata. |
+ |
+ if (equals == null) pop(); // endToken |
+ String name = pop(); |
+ Token metadata = pop(); |
+ |
+ Builder typedefBuilder = lookupBuilder(typedefKeyword, null, name); |
+ |
+ if (metadata != null) { |
+ var listener = createListener(typedefBuilder, memberScope, false); |
Siggi Cherem (dart-lang)
2017/07/28 00:05:14
could we pull this out into a common function? It
scheglov
2017/08/01 17:10:21
Done.
|
+ var parser = new Parser(listener); |
+ parser.parseMetadataStar(metadata); |
+ List<Expression> metadataConstants = listener.finishMetadata(); |
+ Typedef type = typedefBuilder.target; |
+ metadataConstants.forEach(type.addAnnotation); |
} |
+ |
checkEmpty(typedefKeyword.charOffset); |
} |