Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Unified Diff: sdk/lib/_internal/lib/core_patch.dart

Issue 75703002: Revert "This change makes it easier to put type parameters on JavaScript Arrays." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/lib/js_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/lib/js_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698