Skip to content
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

Closed
leafpetersen opened this issue Nov 7, 2018 · 17 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). breaking-change-request This tracks requests for feedback on breaking changes
Milestone

Comments

@leafpetersen
Copy link
Member

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.

@kevmoo kevmoo added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Nov 14, 2018
@leafpetersen leafpetersen added the breaking-change-request This tracks requests for feedback on breaking changes label Nov 14, 2018
@matanlurey
Copy link
Contributor

👍, thanks!

@mit-mit
Copy link
Member

mit-mit commented Nov 30, 2018

@Hixie LGTM'ed via email

@leafpetersen
Copy link
Member Author

@mit-mit LGTM'ed via email

@mit-mit
Copy link
Member

mit-mit commented Jan 28, 2019

@leafpetersen what is the timeline for landing this breaking change?

@leafpetersen
Copy link
Member Author

Implementation issue is here: dart-lang/language#113 . It's on the books for Q1, I tentatively marked it with the 2.2 milestone.

@mit-mit mit-mit added this to the Dart2.2 milestone Feb 4, 2019
@mit-mit mit-mit modified the milestones: Dart2.2, Dart2.2.1 Feb 26, 2019
@vsmenon
Copy link
Member

vsmenon commented Mar 14, 2019

Is this still Q1?

@kmillikin
Copy link

What is the relative priority of this vs. UI as code? This is a small amount of work for CFE but we have only a few weeks left in Q1.

@mit-mit
Copy link
Member

mit-mit commented Mar 14, 2019

UI as code is more urgent

@mit-mit mit-mit modified the milestones: Dart2.2.1, Dart2.3 Mar 14, 2019
@mit-mit
Copy link
Member

mit-mit commented Mar 14, 2019

cc @leafpetersen remind me, did we send a breaking change notification for this to announce?

@leafpetersen
Copy link
Member Author

Yes, I sent out announcements to the usual places.

@vsmenon
Copy link
Member

vsmenon commented Mar 14, 2019

@kmillikin @stereotype441 - Leaf added the impl items to 2.3 as P2. They are soundness issues, but probably rare. Nice to get done, but lower priority than ui-as-code.

@leafpetersen leafpetersen modified the milestones: Dart2.3, Dart 2.4 Mar 19, 2019
@leafpetersen
Copy link
Member Author

It looks like this is going to slip forward another release.

@dgrove
Copy link
Contributor

dgrove commented Mar 21, 2019

LGTM

@aadilmaan
Copy link
Contributor

Leaf - We have all the approvals. You may proceed with this in Dart2.4

@aadilmaan aadilmaan assigned leafpetersen and unassigned aadilmaan Mar 21, 2019
@leafpetersen
Copy link
Member Author

There should be no bad builds to be marked for flutter from the period in which this had landed in the CFE and not the analyzer. The last roll of the engine that I see is flutter/flutter@2f6a986, which includes commits 0308a1c4a Roll src/third_party/dart fde6a5917e..e3edfd36b2 (14 commits) . That commit range does not include either implementation commit.

@dgrove
Copy link
Contributor

dgrove commented Jun 5, 2019

What's remaining here?

@aadilmaan
Copy link
Contributor

Leaf will do the necessary announce via emails groups once we have a release candidate for D24 but will close this issue for now as no engineering work remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). breaking-change-request This tracks requests for feedback on breaking changes
Projects
None yet
Development

No branches or pull requests

8 participants