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

Unified Diff: lib/runtime/dart/_internal.js

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 | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/runtime/dart/collection.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/_internal.js
diff --git a/lib/runtime/dart/_internal.js b/lib/runtime/dart/_internal.js
index 8884b3a8160e29721873af07bcbc75ffa935528b..1999fc0f39ba2fe8e426c0432553be678ef487ab 100644
--- a/lib/runtime/dart/_internal.js
+++ b/lib/runtime/dart/_internal.js
@@ -73,7 +73,9 @@ var _internal;
return false;
}
[core.$firstWhere](test, opts) {
+ dart.as(test, dart.functionType(core.bool, [E]));
let orElse = opts && 'orElse' in opts ? opts.orElse : null;
+ dart.as(orElse, dart.functionType(E, []));
let length = this[core.$length];
for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i) + 1) {
let element = this[core.$elementAt](i);
@@ -88,7 +90,9 @@ var _internal;
throw IterableElementError.noElement();
}
[core.$lastWhere](test, opts) {
+ dart.as(test, dart.functionType(core.bool, [E]));
let orElse = opts && 'orElse' in opts ? opts.orElse : null;
+ dart.as(orElse, dart.functionType(E, []));
let length = this[core.$length];
for (let i = dart.notNull(length) - 1; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) {
let element = this[core.$elementAt](i);
@@ -788,19 +792,25 @@ var _internal;
return false;
}
[core.$firstWhere](test, opts) {
+ dart.as(test, dart.functionType(core.bool, [E]));
let orElse = opts && 'orElse' in opts ? opts.orElse : null;
+ dart.as(orElse, dart.functionType(E, []));
if (orElse != null)
return orElse();
throw IterableElementError.noElement();
}
[core.$lastWhere](test, opts) {
+ dart.as(test, dart.functionType(core.bool, [E]));
let orElse = opts && 'orElse' in opts ? opts.orElse : null;
+ dart.as(orElse, dart.functionType(E, []));
if (orElse != null)
return orElse();
throw IterableElementError.noElement();
}
[core.$singleWhere](test, opts) {
+ dart.as(test, dart.functionType(core.bool, [E]));
let orElse = opts && 'orElse' in opts ? opts.orElse : null;
+ dart.as(orElse, dart.functionType(E, []));
if (orElse != null)
return orElse();
throw IterableElementError.noElement();
@@ -1270,9 +1280,11 @@ var _internal;
throw new core.UnsupportedError("Cannot change the length of a fixed-length list");
}
add(value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot add to a fixed-length list");
}
insert(index, value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot add to a fixed-length list");
}
insertAll(at, iterable) {
@@ -1312,6 +1324,7 @@ var _internal;
let UnmodifiableListMixin$ = dart.generic(function(E) {
class UnmodifiableListMixin extends core.Object {
[core.$set](index, value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot modify an unmodifiable list");
}
set [core.$length](newLength) {
@@ -1321,9 +1334,11 @@ var _internal;
throw new core.UnsupportedError("Cannot modify an unmodifiable list");
}
[core.$add](value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot add to an unmodifiable list");
}
[core.$insert](index, value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot add to an unmodifiable list");
}
[core.$insertAll](at, iterable) {
@@ -1344,6 +1359,7 @@ var _internal;
[core.$sort](compare) {
if (compare === void 0)
compare = null;
+ dart.as(compare, core.Comparator$(E));
throw new core.UnsupportedError("Cannot modify an unmodifiable list");
}
[core.$shuffle](random) {
@@ -1361,6 +1377,7 @@ var _internal;
throw new core.UnsupportedError("Cannot remove from an unmodifiable list");
}
[core.$setRange](start, end, iterable, skipCount) {
+ dart.as(iterable, core.Iterable$(E));
if (skipCount === void 0)
skipCount = 0;
throw new core.UnsupportedError("Cannot modify an unmodifiable list");
@@ -1374,6 +1391,7 @@ var _internal;
[core.$fillRange](start, end, fillValue) {
if (fillValue === void 0)
fillValue = null;
+ dart.as(fillValue, E);
throw new core.UnsupportedError("Cannot modify an unmodifiable list");
}
}
@@ -1445,6 +1463,7 @@ var _internal;
}
}
set(key, value) {
+ dart.as(value, E);
throw new core.UnsupportedError("Cannot modify an unmodifiable map");
}
putIfAbsent(key, ifAbsent) {
« no previous file with comments | « no previous file | lib/runtime/dart/_js_helper.js » ('j') | lib/runtime/dart/collection.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698