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

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: Remove unnecessary null check 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..d990f27e9f64adc4e6d1fd6f83914222094e6c37 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.any((t) => !t.isDynamic);
+ 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