Skip to content

Commit 36373f0

Browse files
author
John Messerly
committed
add checks needed for covariant generics, and fixes #154, List<E> now has the right runtime type.
[email protected] Review URL: https://codereview.chromium.org/1117793002
1 parent da405c9 commit 36373f0

File tree

15 files changed

+689
-88
lines changed

15 files changed

+689
-88
lines changed

pkg/dev_compiler/lib/runtime/dart/_internal.js

Lines changed: 74 additions & 1 deletion
Large diffs are not rendered by default.

pkg/dev_compiler/lib/runtime/dart/_js_helper.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,24 @@ var _js_helper;
4141
throw new core.UnsupportedError("Cannot modify unmodifiable Map");
4242
}
4343
set(key, val) {
44+
dart.as(key, K);
45+
dart.as(val, V);
4446
return this[_throwUnmodifiable]();
4547
}
4648
putIfAbsent(key, ifAbsent) {
49+
dart.as(key, K);
50+
dart.as(ifAbsent, dart.functionType(V, []));
4751
return dart.as(this[_throwUnmodifiable](), V);
4852
}
4953
remove(key) {
54+
dart.as(key, K);
5055
return dart.as(this[_throwUnmodifiable](), V);
5156
}
5257
clear() {
5358
return this[_throwUnmodifiable]();
5459
}
5560
addAll(other) {
61+
dart.as(other, core.Map$(K, V));
5662
return this[_throwUnmodifiable]();
5763
}
5864
}
@@ -73,6 +79,7 @@ var _js_helper;
7379
super._();
7480
}
7581
containsValue(needle) {
82+
dart.as(needle, V);
7683
return this.values[core.$any](value => dart.equals(value, needle));
7784
}
7885
containsKey(key) {
@@ -91,6 +98,7 @@ var _js_helper;
9198
return jsPropertyAccess(this[_jsObject], dart.as(key, core.String));
9299
}
93100
forEach(f) {
101+
dart.as(f, dart.functionType(dart.void, [K, V]));
94102
let keys = this[_keys];
95103
for (let i = 0; core.int['<'](i, dart.dload(keys, 'length')); i = dart.notNull(i) + 1) {
96104
let key = dart.dindex(keys, i);
@@ -164,6 +172,7 @@ var _js_helper;
164172
return this.$map;
165173
}
166174
containsValue(needle) {
175+
dart.as(needle, V);
167176
return this[_getMap]().containsValue(needle);
168177
}
169178
containsKey(key) {
@@ -173,6 +182,7 @@ var _js_helper;
173182
return this[_getMap]().get(key);
174183
}
175184
forEach(f) {
185+
dart.as(f, dart.functionType(dart.void, [K, V]));
176186
this[_getMap]().forEach(f);
177187
}
178188
get keys() {

0 commit comments

Comments
 (0)