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

Unified Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10849002: Support type annotations for list literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/scanner/listener.dart
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 2c6bd2377d52c277fe55a599310486bb91568a22..69edb8da0e3504e9ffbfc0cd0bbfafd31eb2341f 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -1268,8 +1268,15 @@ class NodeListener extends ElementListener {
Token endToken) {
NodeList elements = makeNodeList(count, beginToken, endToken, ',');
NodeList typeArguments = popNode();
- // TODO(ahe): Type arguments are discarded.
- pushNode(new LiteralList(null, elements, constKeyword));
+ TypeAnnotation type = null;
+ if (typeArguments !== null) {
+ if (typeArguments.length() != 1) {
ahe 2012/08/23 13:06:35 The method [length] is O(n). The method [length] s
+ error('Type annotations for list literal should have a single type',
ahe 2012/08/23 13:06:35 If this error should be reported here, it should b
+ constKeyword.next);
ahe 2012/08/23 13:06:35 This error position is wrong. First, there may be
+ }
+ type = typeArguments.iterator().next();
ahe 2012/08/23 13:06:35 Calling iterator always creates a new object. This
+ }
ahe 2012/08/23 13:06:35 Unfortunately, you discarded the NodeList and now
+ pushNode(new LiteralList(type, elements, constKeyword));
}
void handleIndexedExpression(Token openSquareBracket,
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698