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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1611753002: fixes #415, correct type for map literals (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: add TODO Created 4 years, 11 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 | « lib/runtime/dart/html.js ('k') | test/codegen/expect/collection/src/wrappers.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 712ca80e62d4c63ebe2a0e3facc44cbef041d764..88215c42ea58829381a016fc23d2cd62657d85fc 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -3204,7 +3204,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
JS.Expression emitMap() {
var entries = node.entries;
var mapArguments = null;
- if (entries.isEmpty) {
+ var typeArgs = node.typeArguments;
+ if (entries.isEmpty && typeArgs == null) {
mapArguments = [];
} else if (entries.every((e) => e.key is StringLiteral)) {
// Use JS object literal notation if possible, otherwise use an array.
@@ -3223,8 +3224,11 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ClosureAnnotator {
}
mapArguments = new JS.ArrayInitializer(values);
}
- // TODO(jmesserly): add generic types args.
- return js.call('dart.map(#)', [mapArguments]);
+ var types = <JS.Expression>[];
+ if (typeArgs != null) {
+ types.addAll(typeArgs.arguments.map((e) => _emitTypeName(e.type)));
+ }
+ return js.call('dart.map(#, #)', [mapArguments, types]);
}
if (node.constKeyword != null) return _emitConst(emitMap);
return emitMap();
« no previous file with comments | « lib/runtime/dart/html.js ('k') | test/codegen/expect/collection/src/wrappers.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698