Index: sdk/lib/_internal/compiler/implementation/lib/core_patch.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart |
index 372c4d41ead2cafc216b6aebe20836bff8a2593e..4b74f75622a54fe62927977df1a7fcc30bbf9381 100644 |
--- a/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart |
+++ b/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart |
@@ -162,15 +162,17 @@ patch class _StopwatchImpl { |
// Patch for List implementation. |
patch class List<E> { |
patch factory List([int length = 0]) { |
+ // Explicit type test is necessary to protect Primitives.newGrowableList in |
+ // unchecked mode. |
if ((length is !int) || (length < 0)) { |
- String lengthString = Error.safeToString(length); |
- throw new ArgumentError( |
- "Length must be a positive integer: $lengthString."); |
+ throw new ArgumentError("Length must be a positive integer: $length."); |
} |
return Primitives.newGrowableList(length); |
} |
patch factory List.fixedLength(int length, {E fill: null}) { |
+ // Explicit type test is necessary to protect Primitives.newFixedList in |
+ // unchecked mode. |
if ((length is !int) || (length < 0)) { |
throw new ArgumentError("Length must be a positive integer: $length."); |
} |
@@ -188,6 +190,8 @@ patch class List<E> { |
* filled with [fill]. |
*/ |
patch factory List.filled(int length, E fill) { |
+ // Explicit type test is necessary to protect Primitives.newGrowableList in |
+ // unchecked mode. |
if ((length is !int) || (length < 0)) { |
throw new ArgumentError("Length must be a positive integer: $length."); |
} |