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

Unified Diff: tool/input_sdk/patch/core_patch.dart

Issue 1117793002: add checks needed for covariant generics, and List<E> (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months 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 | « test/generated_sdk/lib/core/list.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/patch/core_patch.dart
diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart
index ec57bb0c039f1d94cccb1a1e0a6b6168c69612c9..629116bbab3d95a63c5277fff61f43bd4005bf9c 100644
--- a/tool/input_sdk/patch/core_patch.dart
+++ b/tool/input_sdk/patch/core_patch.dart
@@ -243,23 +243,28 @@ class _ListConstructorSentinel {
class List<E> {
@patch
factory List([int length]) {
+ dynamic list;
if (length == null) {
- return JS('', '[]');
- }
- // 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");
+ list = JS('', '[]');
+ } else {
+ // 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");
+ }
+ list = JS('', 'new Array(#)', length);
+ // TODO(jmesserly): consider a fixed array subclass instead.
+ JS('void', r'#.fixed$length = Array', list);
}
- var list = JS('', 'new Array(#)', length);
- // TODO(jmesserly): consider a fixed array subclass instead.
- JS('void', r'#.fixed$length = Array', list);
+ // TODO(jmesserly): skip this when E is dynamic and Object.
+ JS('void', 'dart.setType(#, List\$(#))', list, E);
+ // TODO(jmesserly): compiler creates a bogus type check here.
return list;
}
@patch
factory List.filled(int length, E fill) {
- List result = new JSArray<E>.fixed(length);
+ List result = new List<E>(length);
if (length != 0 && fill != null) {
for (int i = 0; i < result.length; i++) {
result[i] = fill;
« no previous file with comments | « test/generated_sdk/lib/core/list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698