Dart Breaking Change: Enforce covariance in super-interfaces

61 views
Skip to first unread message

Leaf Petersen

unread,
Nov 7, 2018, 5:40:50 PM11/7/18
to Dart Misc
TL;DR: There is a missing check on the uses of covariant generic parameters in super-interfaces that can be used to violate soundness (and hence memory safety) in Dart programs.  We are proposing to add this missing check as a static error in an upcoming release of Dart.  We have not found any code which would be affected by this new error, but it is possible that some existing working code will break.  

A detailed description of the proposed change can be found here, but in short, we propose to make it an error to use a type parameter of a class in a contravariant or invariant position in any of the classes direct super-interfaces.

This code would become an error after this change:

class A<X> {};
class B<X> extends A<void Function(X)> {};

Please comment on this issue if you believe that you have code which will be affected by this or are otherwise opposed to this change.

thanks,
-leaf

Leaf Petersen

unread,
Jun 7, 2019, 5:03:48 PM6/7/19
to Dart Misc
This change has landed in Dart bleeding edge, and has been released to the dev channel as 2.3.2-dev.0.1.  It has also landed in Flutter master, and has been released to the Flutter dev channel.  If you encounter any issues, feel free to follow up here or with me directly.

-leaf
Reply all
Reply to author
Forward
0 new messages