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

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

Issue 1013223002: coverage: increase coverage of js_codegen (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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 6f135f0d21cad9d566835518470bb9e35b167124..f9ceddb85afe64a7d9c2b4c237f312e33e7d2a4e 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -1624,12 +1624,12 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
if (entries.isEmpty) return js.call('dart.map()');
// Use JS object literal notation if possible, otherwise use an array.
- if (entries.every((e) => e.key is SimpleStringLiteral)) {
+ // We could do this any time all keys are non-nullable String type.
+ // For now, support StringLiteral as the common non-nullable String case.
+ if (entries.every((e) => e.key is StringLiteral)) {
var props = [];
for (var e in entries) {
- var key = (e.key as SimpleStringLiteral).value;
- var value = _visit(e.value);
- props.add(new JS.Property(js.escapedString(key), value));
+ props.add(new JS.Property(_visit(e.key), _visit(e.value)));
}
mapArguments = new JS.ObjectInitializer(props);
} else {
« no previous file with comments | « .gitignore ('k') | test/codegen/expect/map_keys.js » ('j') | test/codegen_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698