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

Unified Diff: dart/frog/leg/scanner/partial_parser.dart

Issue 9808016: Fix bug in partial parsing of map literal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 | dart/tests/language/src/MapLiteralSyntaxTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/scanner/partial_parser.dart
diff --git a/dart/frog/leg/scanner/partial_parser.dart b/dart/frog/leg/scanner/partial_parser.dart
index 8771e73413536cb65292cae622328f7b53e379bb..1e792d0410d289bdf483dfab28e04626e6489b8f 100644
--- a/dart/frog/leg/scanner/partial_parser.dart
+++ b/dart/frog/leg/scanner/partial_parser.dart
@@ -20,16 +20,39 @@ class PartialParser extends Parser {
(value === ',') ||
(value === ']'))
return token;
- if (value === '=' && token.next.stringValue === '{') {
- // Handle cases like this:
- // class Foo {
- // var map;
- // Foo() : map = {};
- // }
- BeginGroupToken begin = token.next;
- token = (begin.endGroup !== null) ? begin.endGroup : token;
- token = token.next;
- continue;
+ if (value === '=') {
+ var nextValue = token.next.stringValue;
+ if (nextValue === 'const') {
+ token = token.next;
+ nextValue = token.next.stringValue;
+ }
+ if (nextValue === '{') {
+ // Handle cases like this:
+ // class Foo {
+ // var map;
+ // Foo() : map = {};
+ // }
+ BeginGroupToken begin = token.next;
+ token = (begin.endGroup !== null) ? begin.endGroup : token;
+ token = token.next;
+ continue;
+ }
+ if (nextValue === '<') {
+ // Handle cases like this:
+ // class Foo {
+ // var map;
+ // Foo() : map = <Foo>{};
+ // }
+ BeginGroupToken begin = token.next;
+ token = (begin.endGroup !== null) ? begin.endGroup : token;
+ token = token.next;
+ if (token.stringValue === '{') {
+ begin = token;
+ token = (begin.endGroup !== null) ? begin.endGroup : token;
+ token = token.next;
+ }
+ continue;
+ }
}
if (!mayParseFunctionExpressions && value === '{')
return token;
« no previous file with comments | « no previous file | dart/tests/language/src/MapLiteralSyntaxTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698