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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1560663004: Parse generic function declarations with/without type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bd1335707a85f1f9d083318efa2a0528ababddc6..33510ed07a8247196bc173ce794b9e16c4339dea 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -4219,6 +4219,14 @@ class Parser {
return _tokenMatches(token, TokenType.OPEN_PAREN);
}
+ bool _isPeekGenericTypeParametersAndOpenParen() {
+ if (!parseGenericMethods) {
+ return false;
+ }
+ Token token = _skipTypeArgumentList(_peek());
+ return token != null && _tokenMatches(token, TokenType.OPEN_PAREN);
+ }
+
/**
* Return `true` if the current token appears to be the beginning of a switch
* member.
@@ -5216,6 +5224,9 @@ class Parser {
}
_reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken);
return null;
+ } else if (_isPeekGenericTypeParametersAndOpenParen()) {
+ return _parseFunctionDeclaration(
+ commentAndMetadata, modifiers.externalKeyword, null);
} else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
TypeName returnType = _parseOptionalTypeNameComment();
_validateModifiersForTopLevelFunction(modifiers);
@@ -5275,7 +5286,8 @@ class Parser {
if (_peek().matchesAny([
TokenType.OPEN_PAREN,
TokenType.FUNCTION,
- TokenType.OPEN_CURLY_BRACKET
+ TokenType.OPEN_CURLY_BRACKET,
+ TokenType.LT
])) {
_validateModifiersForTopLevelFunction(modifiers);
return _parseFunctionDeclaration(
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698