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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 13467021: Register type for literal list/map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 6853893a4958a4bd26a2008f03b783889ad084fa..ab1b7baea877ae9e110ee4b0776dbc9eadc876c8 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -2618,8 +2618,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
listType = new InterfaceType(compiler.listClass,
new Link<DartType>.fromList([typeArgument]));
} else {
+ compiler.listClass.computeType(compiler);
listType = compiler.listClass.rawType;
}
+ mapping.setType(node, listType);
world.registerInstantiatedType(listType, mapping);
visit(node.elements);
}
@@ -2775,6 +2777,36 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
visitLiteralMap(LiteralMap node) {
+ NodeList arguments = node.typeArguments;
+ DartType keyTypeArgument;
+ DartType valueTypeArgument;
+ if (arguments != null) {
+ Link<Node> nodes = arguments.nodes;
+ if (nodes.isEmpty) {
+ error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
+ } else {
+ keyTypeArgument = resolveTypeRequired(nodes.head);
+ nodes = nodes.tail;
+ if (nodes.isEmpty) {
+ error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
+ } else {
+ valueTypeArgument = resolveTypeRequired(nodes.head);
+ for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) {
+ error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
+ resolveTypeRequired(nodes.head);
+ }
+ }
+ }
+ }
+ DartType mapType;
+ if (valueTypeArgument != null) {
+ mapType = new InterfaceType(compiler.mapClass,
+ new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument]));
+ } else {
+ compiler.mapClass.computeType(compiler);
+ mapType = compiler.mapClass.rawType;
+ }
+ mapping.setType(node, mapType);
world.registerInstantiatedClass(compiler.mapClass, mapping);
if (node.isConst()) {
compiler.backend.registerConstantMap(mapping);

Powered by Google App Engine
This is Rietveld 408576698