Index: pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart |
diff --git a/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart b/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart |
index 41835b636bb774e29265589a8e1eef111592cbe5..353f2310b2cfab27568fc8f7870ce4f6e0018ea9 100644 |
--- a/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart |
+++ b/pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart |
@@ -21,6 +21,8 @@ import 'dart:_js_helper' |
Primitives, |
stringJoinUnchecked; |
+import 'dart:_runtime' show undefined; |
+ |
import 'dart:_foreign_helper' show JS; |
import 'dart:_native_typed_data' show NativeUint8List; |
@@ -321,39 +323,39 @@ class Stopwatch { |
@patch |
class List<E> { |
@patch |
- factory List([int _length]) { |
+ factory List([_length = undefined]) { |
Jennifer Messerly
2017/08/25 18:08:57
the List constructor does a weird thing in dart2js
|
dynamic list; |
- if (_length == null) { |
+ if (JS('bool', '# === void 0', _length)) { |
Jennifer Messerly
2017/08/25 18:08:58
maybe we should recognize `undefined` in other pla
|
list = JS('', '[]'); |
} else { |
- @notNull |
- var length = _length; |
- if (length < 0) { |
+ var length = JS('int', '#', _length); |
+ if (_length == null || length < 0) { |
throw new ArgumentError( |
- "Length must be a non-negative integer: $length"); |
+ "Length must be a non-negative integer: $_length"); |
} |
- list = JSArray.markFixedList(JS('', 'new Array(#)', length)); |
+ list = JS('', 'new Array(#)', length); |
+ JSArray.markFixedList(list); |
} |
return new JSArray<E>.of(list); |
} |
@patch |
- factory List.filled(int length, E fill, {bool growable: true}) { |
- List<E> result = new List<E>(length); |
+ factory List.filled(@nullCheck int length, E fill, {bool growable: false}) { |
Jennifer Messerly
2017/08/25 18:08:58
there's a couple of bug fixes here
|
+ var list = new JSArray<E>.of(JS('', 'new Array(#)', length)); |
Jennifer Messerly
2017/08/25 18:08:58
this was incorrectly fixed in the old code because
|
if (length != 0 && fill != null) { |
@notNull |
- var length = result.length; |
+ var length = list.length; |
for (int i = 0; i < length; i++) { |
- result[i] = fill; |
+ list[i] = fill; |
} |
} |
- if (growable) return result; |
- return makeListFixedLength<E>(result); |
+ if (!growable) JSArray.markFixedList(list); |
+ return list; |
} |
@patch |
factory List.from(Iterable elements, {bool growable: true}) { |
- List<E> list = new List<E>(); |
+ var list = new JSArray<E>.of(JS('', '[]')); |
// Specialize the copy loop for the case that doesn't need a |
// runtime check. |
if (elements is Iterable<E>) { |
@@ -365,14 +367,15 @@ class List<E> { |
list.add(e as E); |
} |
} |
- if (growable) return list; |
- return makeListFixedLength/*<E>*/(list); |
+ if (!growable) JSArray.markFixedList(list); |
+ return list; |
} |
@patch |
factory List.unmodifiable(Iterable elements) { |
- var result = new List<E>.from(elements, growable: false); |
- return makeFixedListUnmodifiable/*<E>*/(result); |
+ var list = new List<E>.from(elements); |
+ JSArray.markUnmodifiableList(list); |
+ return list; |
} |
} |