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

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: 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
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 6c98ba55310c4645181dd7d89c8abab27d0b2631..5d17009dd656209af7ea01da6b586751cbc77890 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -3251,7 +3251,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.
@@ -3270,8 +3271,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();

Powered by Google App Engine
This is Rietveld 408576698