-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onsoundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dev-compiler
Description
From @jmesserly on May 1, 2015 20:9
we need to add covariance checks for parameters, e.g. List<E>.add ... given
class Foo<T> {
T _t;
add(T t) {
_t = t;
}
forEach(void fn(T t)) {
// No check needed for `fn`
fn(_t);
}
}
class Bar extends Foo<int> {
add(int x) {
print('Bar.add got $x');
super.add(x);
}
}
main() {
Foo<Object> foo = new Bar();
foo.add('hi'); // should throw
}currently I'm adding something simple to JS codegen, but it adds extra checks (Foo.forEach) and it misses checks (Bar.add). Also ideally we'd compute this earlier, in checker/coercion reifier.
Copied from original issue: dart-archive/dev_compiler#161
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onsoundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dev-compiler