Description
It is currently possible to subvert the Dart type system in the class hierarchy because of a missing check on the use of covariant generic type parameters. Discussion of the consequences of this can be found here, but in short it can cause soundness violations. We propose to make the problematic uses errors as described here.
Change Summary After this change, using the type parameter of a generic class non-covariantly in a direct super-interface of a class would be an error. Example:
class A<X> {};
class B<X> extends A<void Function(X)> {};
The definition of B
would cause a static error after this change.
Justification Missing this check allows Dart programs to subvert the type system, resulting in undefined (unsafe) behavior. For an example, see this issue.
Impact We expect the impact of this to be minimal. I have analyzed all internal google code and all of the flutter framework code and found no examples of code which would be impacted by this.
Mitigation We do not expect to be able to provide tooling to migrate any code impacted by this change. We might consider releasing this as a warning for some number of dev releases (or possibly even a stable release cycle) before promoting it to an error to ensure that users have time to migrate any affected code.