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

Unified Diff: runtime/vm/parser.cc

Issue 2911333002: Allow a function named 'get' to be generic (fixes #29746). (Closed)
Patch Set: 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 | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 125d54db8249e57d88ce00bae8fc730edb72d63e..c5cc870457d1efca83ec37264fff7e6e32a7a5cb 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -5542,6 +5542,15 @@ void Parser::SkipTypeArguments() {
}
+void Parser::SkipTypeParameters() {
+ // Function already parsed, no need to check FLAG_generic_method_syntax.
+ if (IsTypeParameters()) {
+ const bool skipped = TryParseTypeParameters();
+ ASSERT(skipped);
+ }
+}
+
+
void Parser::SkipType(bool allow_void) {
if (CurrentToken() == Token::kVOID) {
if (!allow_void) {
@@ -14857,17 +14866,23 @@ void Parser::SkipFunctionLiteral() {
// previously parsed the function.
void Parser::SkipFunctionPreamble() {
while (true) {
- const Token::Kind token = CurrentToken();
if (IsFunctionTypeSymbol()) {
ConsumeToken();
- SkipTypeArguments();
+ SkipTypeParameters();
SkipToMatchingParenthesis();
continue;
}
+ const Token::Kind token = CurrentToken();
if (token == Token::kLPAREN) {
return;
}
if (token == Token::kGET) {
+ if (LookaheadToken(1) == Token::kLT) {
+ // Case: Generic Function/method named get.
+ ConsumeToken(); // Parse away 'get' (the function's name).
+ SkipTypeParameters();
+ continue;
+ }
if (LookaheadToken(1) == Token::kLPAREN) {
// Case: Function/method named get.
ConsumeToken(); // Parse away 'get' (the function's name).
@@ -14878,7 +14893,7 @@ void Parser::SkipFunctionPreamble() {
ConsumeToken(); // Parse away the getter name.
return;
}
- ConsumeToken();
+ ConsumeToken(); // Can be static, factory, operator, void, ident, etc...
}
}
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698