Index: pkg/analyzer/lib/src/generated/parser.dart |
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart |
index 4810f5221c5098cc85aa58d469fd554ecaf67a6d..33eba26d683875fa8ab9bdf729882c49f13f2e89 100644 |
--- a/pkg/analyzer/lib/src/generated/parser.dart |
+++ b/pkg/analyzer/lib/src/generated/parser.dart |
@@ -542,7 +542,7 @@ class Parser { |
// There was no type name, so this can't be a declaration. |
return false; |
} |
- if (_atGenericFunctionTypeAfterReturnType(token)) { |
+ while (_atGenericFunctionTypeAfterReturnType(token)) { |
token = skipGenericFunctionTypeAfterReturnType(token); |
if (token == null) { |
// There was no type name, so this can't be a declaration. |
@@ -4061,24 +4061,22 @@ class Parser { |
])) { |
return _parseFunctionDeclarationStatementAfterReturnType( |
commentAndMetadata, returnType); |
- } else { |
- // |
- // We have found an error of some kind. Try to recover. |
- // |
- if (_matchesIdentifier()) { |
- if (next.matchesAny(const <TokenType>[ |
+ } else if (_matchesIdentifier() && |
+ next.matchesAny(const <TokenType>[ |
TokenType.EQ, |
TokenType.COMMA, |
TokenType.SEMICOLON |
])) { |
- // |
- // We appear to have a variable declaration with a type of "void". |
- // |
- _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); |
- return parseVariableDeclarationStatementAfterMetadata( |
- commentAndMetadata); |
- } |
- } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
+ if (returnType is! GenericFunctionType) { |
+ _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); |
+ } |
+ return _parseVariableDeclarationStatementAfterType( |
+ commentAndMetadata, null, returnType); |
+ } else { |
+ // |
+ // We have found an error of some kind. Try to recover. |
+ // |
+ if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
// |
// We appear to have found an incomplete statement at the end of a |
// block. Parse it as a variable declaration. |