New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change Request: Enforce covariance of type variables in super-interfaces #35097

leafpetersen opened this Issue Nov 7, 2018 · 0 comments


None yet
2 participants

leafpetersen commented Nov 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment