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

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

Issue 2640963003: Disable generic function types (Closed)
Patch Set: Created 3 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 9ac9bc8994bdd6c97bd4fbc6826876f4dcfd6e5b..e470237d00a613b0ac1035da16b0c71221797083 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -243,6 +243,12 @@ class Parser {
bool _inInitializer = false;
/**
+ * A flag indicating whether the parser is to parse generic function type
+ * syntax.
+ */
+ bool parseGenericFunctionTypes = false;
+
+ /**
* A flag indicating whether the parser is to parse generic method syntax.
*/
@deprecated
@@ -4993,21 +4999,24 @@ class Parser {
* | functionType
*/
TypeAnnotation parseTypeAnnotation(bool inExpression) {
- TypeAnnotation type = null;
- if (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
- // Generic function type with no return type.
- type = parseGenericFunctionTypeAfterReturnType(null);
- } else if (_currentToken.keyword == Keyword.VOID &&
- _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
- type = astFactory.typeName(
- astFactory.simpleIdentifier(getAndAdvance()), null);
- } else {
- type = parseTypeName(inExpression);
- }
- while (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
- type = parseGenericFunctionTypeAfterReturnType(type);
+ if (parseGenericFunctionTypes) {
+ TypeAnnotation type = null;
+ if (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
+ // Generic function type with no return type.
+ type = parseGenericFunctionTypeAfterReturnType(null);
+ } else if (_currentToken.keyword == Keyword.VOID &&
+ _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
+ type = astFactory.typeName(
+ astFactory.simpleIdentifier(getAndAdvance()), null);
+ } else {
+ type = parseTypeName(inExpression);
+ }
+ while (_atGenericFunctionTypeAfterReturnType(_currentToken)) {
+ type = parseGenericFunctionTypeAfterReturnType(type);
+ }
+ return type;
}
- return type;
+ return parseTypeName(inExpression);
}
/**
@@ -5468,19 +5477,22 @@ class Parser {
* This method must be kept in sync with [parseTypeAnnotation].
*/
Token skipTypeAnnotation(Token startToken) {
- Token next = null;
- if (_atGenericFunctionTypeAfterReturnType(startToken)) {
- next = skipGenericFunctionTypeAfterReturnType(startToken);
- } else if (_currentToken.keyword == Keyword.VOID &&
- _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
- next = next.next;
- } else {
- next = skipTypeName(startToken);
- }
- while (next != null && _tokenMatchesString(next, 'Function')) {
- next = skipGenericFunctionTypeAfterReturnType(next);
+ if (parseGenericFunctionTypes) {
+ Token next = null;
+ if (_atGenericFunctionTypeAfterReturnType(startToken)) {
+ next = skipGenericFunctionTypeAfterReturnType(startToken);
+ } else if (_currentToken.keyword == Keyword.VOID &&
+ _atGenericFunctionTypeAfterReturnType(_currentToken.next)) {
+ next = next.next;
+ } else {
+ next = skipTypeName(startToken);
+ }
+ while (next != null && _tokenMatchesString(next, 'Function')) {
+ next = skipGenericFunctionTypeAfterReturnType(next);
+ }
+ return next;
}
- return next;
+ return skipTypeName(startToken);
}
/**
« 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