| 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,
|
|
|