Closed
Description
Cf. dart-lang/language#925, consider the following program:
class A {}
class B extends A {}
class C {
// The parameter `b` is not covariant-by-declaration as seen from here.
void f(B b) {}
}
abstract class I {
// If `I` is a superinterface of any class,
// the parameter of its `f` is covariant-by-declaration.
void f(covariant A a);
}
class D extends C implements I {} // OK.
void main() {
I i = D();
i.f(A()); // Dynamic type error.
}
The class D
will behave in such a way that the actual argument to its f
method has its type checked dynamically. In other words, when C.f
is inherited by D
, it is changed such that it's parameter is covariant-by-declaration. (This may be achieved by implicitly inducing a forwarding stub into D
that calls super.f(...)
, but it could also be done by other means.)
This issue is concerned with the implementation of this feature. The tests added in https://dart-review.googlesource.com/c/sdk/+/208504 can be used as a guide.
This is not tied to a language version or a flag, because it only allows programs with errors to become running programs.
Subtasks: