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 |