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

Unified Diff: lib/src/compiler/code_generator.dart

Issue 2211293002: Reify type params on map literals (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Suppress empty arg with dynamic params Created 4 years, 4 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_sdk.js ('k') | test/codegen/language/map_literal11_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index 15a99c1d0764379f27df974bd20364546d2e1e5b..5c384bc04c3feacfb4f1ab891276a2f4d69f78e3 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -4944,8 +4944,10 @@ class CodeGenerator extends GeneralizingAstVisitor
JS.Expression emitMap() {
var entries = node.entries;
var mapArguments = null;
- var typeArgs = node.typeArguments;
- if (entries.isEmpty && typeArgs == null) {
+ var type = node.staticType as InterfaceType;
+ var typeArgs = type.typeArguments;
+ var reifyTypeArgs = typeArgs != null && typeArgs.any((t) => !t.isDynamic);
Jennifer Messerly 2016/08/05 13:48:32 typeArguments should never be null on an Interface
vsm 2016/08/05 14:15:03 Removed - thanks!
+ if (entries.isEmpty && !reifyTypeArgs) {
mapArguments = [];
} else if (entries.every((e) => e.key is StringLiteral)) {
// Use JS object literal notation if possible, otherwise use an array.
@@ -4965,8 +4967,8 @@ class CodeGenerator extends GeneralizingAstVisitor
mapArguments = new JS.ArrayInitializer(values);
}
var types = <JS.Expression>[];
- if (typeArgs != null) {
- types.addAll(typeArgs.arguments.map((e) => _emitType(e.type)));
+ if (reifyTypeArgs) {
+ types.addAll(typeArgs.map((e) => _emitType(e)));
}
return js.call('dart.map(#, #)', [mapArguments, types]);
}
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | test/codegen/language/map_literal11_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698