-
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 onfront-end-missing-errorlegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.soundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Consider the following program:
class A {
num foo(int n) {
print(n.runtimeType); // 'double'
return 1.1;
}
}
abstract class B<X> {
X foo(X x);
}
class C extends A with B<num> {}
void main() {
C a = C();
a.foo(1.2);
}
This program is rejected by the analyzer, as it should be:
error • 'A.foo' ('num Function(int)') isn't a valid concrete implementation of 'B.foo' ('num Function(num)'). • n034.dart:12:7 • invalid_implementation_override
However, the CFE does not detect this override error. With dart
, it generates code where A.foo
isn't overridden, and A.foo
does not check the type of the actual argument, so we reach print(n.runtimeType)
and it prints 'double', which is a soundness violation.
Note that this isn't exclusively a matter for the CFE: dart2js
does perform the type check at the invocation of foo
, so it does throw.
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onfront-end-missing-errorlegacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.soundnesstype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)