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

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

Issue 2699073003: Support `void` as generic argument.
Patch Set: Shuffle things around to have a better `voidRti` locality. Created 3 years, 7 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 | « pkg/compiler/lib/src/typechecker.dart ('k') | pkg/front_end/lib/src/scanner/token.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f1cf87e4b4b12e43085c0b7fbda53a6b45c56033..0b75d4da9d253f9f01d847a0fc75c80928b91db1 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -564,7 +564,7 @@ class Parser {
token = expect('=', token);
token = parseType(token);
} else {
- token = parseReturnTypeOpt(token.next);
+ token = parseTypeOpt(token.next);
token = parseIdentifier(token, IdentifierContext.typedefDeclaration);
token = parseTypeVariablesOpt(token);
token = parseFormalParameters(token);
@@ -583,19 +583,6 @@ class Parser {
return token;
}
- Token parseReturnTypeOpt(Token token) {
- if (identical(token.stringValue, 'void')) {
- if (isGeneralizedFunctionType(token.next)) {
- return parseType(token);
- } else {
- listener.handleVoidKeyword(token);
- return token.next;
- }
- } else {
- return parseTypeOpt(token);
- }
- }
-
Token parseFormalParametersOpt(Token token) {
if (optional('(', token)) {
return parseFormalParameters(token);
@@ -693,7 +680,7 @@ class Parser {
listener.handleNoName(token);
}
} else {
- token = parseReturnTypeOpt(token);
+ token = parseTypeOpt(token);
if (optional('this', token)) {
thisKeyword = token;
token = expect('.', token.next);
@@ -1048,7 +1035,7 @@ class Parser {
if (context.inDeclaration) {
reportRecoverableErrorCodeWithToken(
token, codeBuiltInIdentifierInDeclaration);
- } else if (!optional("dynamic", token)) {
+ } else if (!optional("dynamic", token) && !optional("void", token)) {
reportRecoverableErrorCodeWithToken(token, codeBuiltInIdentifierAsType);
}
} else if (!inPlainSync && token.isPseudo) {
@@ -1125,10 +1112,6 @@ class Parser {
// Push the non-existing return type first. The loop below will
// generate the full type.
listener.handleNoType(token);
- } else if (identical(token.stringValue, 'void') &&
- isGeneralizedFunctionType(token.next)) {
- listener.handleVoidKeyword(token);
- token = token.next;
} else {
if (isValidTypeReference(token)) {
token = parseIdentifier(token, IdentifierContext.typeReference);
@@ -1403,13 +1386,6 @@ class Parser {
if (!hasType) {
listener.handleNoType(name);
- } else if (optional('void', type) &&
- !isGeneralizedFunctionType(type.next)) {
- listener.handleNoType(name);
- // TODO(ahe): This error is reported twice, second time is from
- // [parseVariablesDeclarationMaybeSemicolon] via
- // [PartialFieldListElement.parseNode].
- reportRecoverableErrorCode(type, codeInvalidVoid);
} else {
parseType(type);
if (isVar) {
@@ -1463,7 +1439,7 @@ class Parser {
if (type == null) {
listener.handleNoType(name);
} else {
- parseReturnTypeOpt(type);
+ parseTypeOpt(type);
}
Token token =
parseIdentifier(name, IdentifierContext.topLevelFunctionDeclaration);
@@ -1830,7 +1806,7 @@ class Parser {
/// If [token] is the start of a type, returns the token after that type.
/// If [token] is not the start of a type, null is returned.
Token peekAfterIfType(Token token) {
- if (!optional('void', token) && !token.isIdentifier) {
+ if (!token.isIdentifier) {
return null;
}
return peekAfterType(token);
@@ -2016,7 +1992,7 @@ class Parser {
if (type == null) {
listener.handleNoType(name);
} else {
- parseReturnTypeOpt(type);
+ parseTypeOpt(type);
}
Token token;
if (optional('operator', name)) {
@@ -2121,7 +2097,7 @@ class Parser {
token = parseOperatorName(token);
} else {
// <type>? <get>? <name>
- token = parseReturnTypeOpt(token);
+ token = parseTypeOpt(token);
if (identical(getOrSet, token)) {
token = token.next;
}
@@ -2175,7 +2151,7 @@ class Parser {
Token beginToken = token;
listener.beginFunction(token);
listener.handleModifiers(0);
- token = parseReturnTypeOpt(token);
+ token = parseTypeOpt(token);
listener.beginFunctionName(token);
token = parseIdentifier(token, IdentifierContext.functionExpressionName);
listener.endFunctionName(beginToken, token);
@@ -2391,8 +2367,6 @@ class Parser {
} else if (identical(value, 'throw') && optional(';', token.next)) {
// TODO(kasperl): Stop dealing with throw here.
return parseRethrowStatement(token);
- } else if (identical(value, 'void')) {
- return parseExpressionStatementOrDeclaration(token);
} else if (identical(value, 'while')) {
return parseWhileStatement(token);
} else if (identical(value, 'do')) {
@@ -2491,7 +2465,7 @@ class Parser {
if (!inPlainSync && optional("await", token)) {
return parseExpressionStatement(token);
}
- assert(token.isIdentifier || identical(token.stringValue, 'void'));
+ assert(token.isIdentifier);
Token identifier = peekIdentifierAfterType(token);
if (identifier != null) {
assert(identifier.isIdentifier);
@@ -2921,8 +2895,6 @@ class Parser {
return parseNewExpression(token);
} else if (identical(value, "const")) {
return parseConstExpression(token);
- } else if (identical(value, "void")) {
- return parseFunctionExpression(token);
} else if (!inPlainSync &&
(identical(value, "yield") || identical(value, "async"))) {
return expressionExpected(token);
« no previous file with comments | « pkg/compiler/lib/src/typechecker.dart ('k') | pkg/front_end/lib/src/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698