| Index: sdk/lib/_internal/lib/core_patch.dart
|
| diff --git a/sdk/lib/_internal/lib/core_patch.dart b/sdk/lib/_internal/lib/core_patch.dart
|
| index de1c0c0f6afc5c08501971bf9e6e2c53ea6ef808..84d7c1f152488fe60c91bc37f1911b19b9f85713 100644
|
| --- a/sdk/lib/_internal/lib/core_patch.dart
|
| +++ b/sdk/lib/_internal/lib/core_patch.dart
|
| @@ -11,6 +11,9 @@ import 'dart:_js_helper' show checkNull,
|
| Primitives,
|
| stringJoinUnchecked,
|
| objectHashCode;
|
| +import 'dart:_js_primitives' show
|
| + newFixedList,
|
| + newGrowableList;
|
|
|
| String _symbolToString(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
|
|
|
| @@ -190,12 +193,22 @@ patch class Stopwatch {
|
| // Patch for List implementation.
|
| patch class List<E> {
|
| patch factory List([int length]) {
|
| - if (length == null) return new JSArray<E>.emptyGrowable();
|
| - return new JSArray<E>.fixed(length);
|
| + if (length == null) return newGrowableList(0);
|
| + // Explicit type test is necessary to protect [newFixedList] in
|
| + // unchecked mode.
|
| + if ((length is !int) || (length < 0)) {
|
| + throw new ArgumentError("Length must be a positive integer: $length.");
|
| + }
|
| + return newFixedList(length);
|
| }
|
|
|
| patch factory List.filled(int length, E fill) {
|
| - List result = new JSArray<E>.fixed(length);
|
| + // Explicit type test is necessary to protect [newFixedList] in
|
| + // unchecked mode.
|
| + if ((length is !int) || (length < 0)) {
|
| + throw new ArgumentError("Length must be a positive integer: $length.");
|
| + }
|
| + List result = newFixedList(length);
|
| if (length != 0 && fill != null) {
|
| for (int i = 0; i < result.length; i++) {
|
| result[i] = fill;
|
|
|