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

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

Issue 2006443002: Use factory constructor for list literals (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 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') | tool/input_sdk/private/js_array.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 69b6ebff8be7c9bf09492da6a226c8a8ab27613e..fe4cb839604813271212515cc00531e048fd9819 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -4235,9 +4235,14 @@ class CodeGenerator extends GeneralizingAstVisitor
if (!elementType.isDynamic || isConst) {
// dart.list helper internally depends on _interceptors.JSArray.
_declareBeforeUse(_jsArray);
- var typeRep = _emitType(elementType);
- var helper = (isConst) ? 'constList' : 'list';
- list = js.call('dart.${helper}(#, #)', [list, typeRep]);
+ if (isConst) {
+ var typeRep = _emitType(elementType);
+ list = js.call('dart.constList(#, #)', [list, typeRep]);
+ } else {
+ // Call `new JSArray<E>.of(list)`
+ var jsArrayType = _jsArray.type.instantiate(type.typeArguments);
+ list = js.call('#.of(#)', [_emitType(jsArrayType), list]);
+ }
}
return list;
}
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698