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

Unified Diff: tool/input_sdk/private/js_array.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/src/compiler/code_generator.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/js_array.dart
diff --git a/tool/input_sdk/private/js_array.dart b/tool/input_sdk/private/js_array.dart
index 83d2c4d9985a95a0d2ea4b9ad11f7cfef896f419..bfb0a59a3a298d8f3876af582738e34c94b533ea 100644
--- a/tool/input_sdk/private/js_array.dart
+++ b/tool/input_sdk/private/js_array.dart
@@ -22,6 +22,16 @@ class JSArray<E> implements List<E>, JSIndexable {
// TODO(jmesserly): skip this when E is dynamic and Object.
JS('-dynamic', 'dart.list(#, #)', allocation, E);
+ /**
+ * Constructor for adding type parameters to an existing JavaScript
+ * Array. Used for creating literal lists.
+ */
+ factory JSArray.of(allocation) {
+ // TODO(sra): Move this to core.List for better readability.
+ // Capture the parameterized ES6 'JSArray' class.
+ return JS('-dynamic', 'dart.setType(#, JSArray)', allocation);
+ }
+
// TODO(jmesserly): consider a fixed array subclass instead.
factory JSArray.markFixed(allocation) =>
new JSArray<E>.typed(markFixedList(allocation));
« no previous file with comments | « lib/src/compiler/code_generator.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698