Chromium Code Reviews| Index: sdk/lib/_internal/js_runtime/lib/js_array.dart |
| diff --git a/sdk/lib/_internal/js_runtime/lib/js_array.dart b/sdk/lib/_internal/js_runtime/lib/js_array.dart |
| index f6bcbbbe6d382bdd4a1e136d6ff73bc0fa84b918..51a8fb4dc1ee4eb3eeac3bff547ed79dace4ab5e 100644 |
| --- a/sdk/lib/_internal/js_runtime/lib/js_array.dart |
| +++ b/sdk/lib/_internal/js_runtime/lib/js_array.dart |
| @@ -22,8 +22,14 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable { |
| factory JSArray.fixed(int 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"); |
| + if (length is !int) { |
| + throw new ArgumentError.value(length, "length", "is not an integer"); |
| + } |
| + // The JavaScript Array constructor with one argument throws if |
| + // the value is not a UInt32. Give a better error message. |
| + int maxJSArrayLength = 0xFFFFFFFF; |
| + if (length < 0 || length > maxJSArrayLength) { |
| + throw new RangeError.range(length, 0, maxJSArrayLength, "length"); |
| } |
| return new JSArray<E>.markFixed(JS('', 'new Array(#)', length)); |
| } |
| @@ -208,8 +214,10 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable { |
| } |
| void addAll(Iterable<E> collection) { |
| + int i = this.length; |
| checkGrowable('addAll'); |
|
sra1
2015/07/08 09:57:01
Keep this line first. It is effectively a receiver
Lasse Reichstein Nielsen
2015/07/08 10:52:31
Acknowledged.
|
| for (E e in collection) { |
| + assert(i++ == this.length || (throw new ConcurrentModificationError(this))); |
| JS('void', r'#.push(#)', this, e); |
| } |
| } |