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

Change extension types such that they must declare subtype relations to Object #3434

Merged
merged 6 commits into from
Nov 17, 2023

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Oct 26, 2023

See the proposal in #3415. This PR changes the extension type feature specification such that the nullability of the representation type does not matter for the determination of the superinterface graph and subtype relationships of the types expressed based on a given extension type declaration:

An extension type is always a proper subtype of Object?, and as such it is potentially nullable (unless some further subtype relations exist). An extension type can declare that it implements T for various T, and this may cause the extension type to be a subtype of Object (directly or indirectly). In this case the extension type is non-nullable.

This change is a substantial simplification because the superinterface graph is shared among of all types E<T1 .. Tk> where E resolves to an extension type declaration (which includes the non-generic case when k is 0).

(In contrast, with the current feature specification, we could have an extension type E such that the superinterface graph of E<int> was different from the superinterface graph of E<int?>. They will now always have the same superinterface graph, though possibly with different actual type arguments in each node of the graph.)

@eernstg eernstg requested a review from lrhn October 26, 2023 10:23
@eernstg eernstg changed the title Change extension types such that the must declare subtype relations to Object Change extension types such that they must declare subtype relations to Object Oct 26, 2023
@eernstg
Copy link
Member Author

eernstg commented Oct 26, 2023

@scheglov, @johnniwinther, @chloestefantsova, the language team accepted this simplification of the rules about the superinterface graph structure of an extension type.

Sorry about the wasted work which has been done in order to handle the previous ruleset! Nevertheless, I'm sure we will be happy in the future about having these new, simpler rules.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Nov 1, 2023
This is a prerequisite to the implementation of
dart-lang/language#3434

Closes #53840
Part of #49731

Change-Id: Ib3bb5961cd8c4919cbc8c8ba37ac4d76fb72a3de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333000
Commit-Queue: Chloe Stefantsova <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
@eernstg
Copy link
Member Author

eernstg commented Nov 15, 2023

Is this one ready to land? The text still says that for the purpose of computing the Dart 1 least upper bound, we pretend that the superinterface graph has a top node. That's simple to say and simple to understand, but the existence of the top node may be controversial, even though it's clearly labeled as being only for this single purpose.

@eernstg eernstg merged commit 2edfa84 into main Nov 17, 2023
3 checks passed
@eernstg eernstg deleted the spec_3415_declare_nonnull_oct23 branch November 17, 2023 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants