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

Unified Diff: tool/input_sdk/patch/core_patch.dart

Issue 1071393007: fuse List and js Array together and a few other misc fixes. (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Created 5 years, 8 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: tool/input_sdk/patch/core_patch.dart
diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart
index ddd7e0a2ce7e7d8c9b062fb0fe34cce32488f2f5..521674fc761c6e5cfb6ff6dd11685f27e228efb7 100644
--- a/tool/input_sdk/patch/core_patch.dart
+++ b/tool/input_sdk/patch/core_patch.dart
@@ -242,11 +242,18 @@ class _ListConstructorSentinel {
@patch
class List<E> {
@patch
- factory List([int length = const _ListConstructorSentinel()]) {
Jennifer Messerly 2015/04/22 21:14:19 wow, craziness
Jacob 2015/04/22 22:58:32 yep. this just in... new List() should fail check
- if (length == const _ListConstructorSentinel()) {
- return new JSArray<E>.emptyGrowable();
+ factory List([int length]) {
+ if (length == null) {
+ return JS('', '[]');
}
- return new JSArray<E>.fixed(length);
+ // Explicit type test is necessary to guard against JavaScript conversions
+ // in unchecked mode.
+ if ((length is !int) || (length < 0)) {
+ throw new ArgumentError("Length must be a non-negative integer: $length");
+ }
+ var list = JS('', 'new Array(#)', length);
+ JS('void', r'#.fixed$length = Array', list);
Jennifer Messerly 2015/04/22 21:14:19 maybe TODO to revisit this? e.g. TODO(jmesserly):
Jacob 2015/04/22 22:58:32 Done. I like adding TODO(jmesserly) better than TO
+ return list;
}
@patch

Powered by Google App Engine
This is Rietveld 408576698