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

Unified Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2963473004: Generate type variable events before parsing return type. (Closed)
Patch Set: Created 3 years, 6 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
Index: pkg/front_end/lib/src/fasta/parser/parser.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index 12fb7b880ebc83fb65c33e52311279e38ddd905c..fff73e2b653069a3792fe1981a9893b695c7888c 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -1283,7 +1283,13 @@ class Parser {
/// function will call the appropriate event methods on [listener] to
/// handle the type.
Token commitType() {
- assert(typeVariableStarters.length == functionTypes);
+ int count = 0;
+ for (Token typeVariableStart in typeVariableStarters) {
+ count++;
+ parseTypeVariablesOpt(typeVariableStart);
+ listener.beginFunctionType(begin);
+ }
+ assert(count == functionTypes);
if (functionTypes > 0 && !hasReturnType) {
// A function type without return type.
@@ -1312,11 +1318,17 @@ class Parser {
}
}
- // While we see a `Function(` treat the pushed type as return type.
- // For example: `int Function() Function(int) Function(String x)`.
for (int i = 0; i < functionTypes; i++) {
- assert(isGeneralizedFunctionType(token));
- token = parseFunctionType(token);
+ assert(optional('Function', token));
+ Token functionToken = token;
+ token = token.next;
+ if (optional("<", token)) {
+ // Skip type parameters, they were parsed above.
+ token = getClose(token).next;
+ }
+ token =
+ parseFormalParameters(token, MemberKind.GeneralizedFunctionType);
+ listener.endFunctionType(functionToken, token);
}
return token;
@@ -1472,19 +1484,6 @@ class Parser {
throw "Internal error: Unhandled continuation '$continuation'.";
}
- /// Parses a generalized function type.
- ///
- /// The return type must already be pushed.
- Token parseFunctionType(Token token) {
- assert(optional('Function', token));
- Token functionToken = token;
- token = token.next;
- token = parseTypeVariablesOpt(token);
- token = parseFormalParameters(token, MemberKind.GeneralizedFunctionType);
- listener.endFunctionType(functionToken, token);
- return token;
- }
-
Token parseTypeArgumentsOpt(Token token) {
return parseStuff(
token,
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698