-
Notifications
You must be signed in to change notification settings - Fork 205
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
Extension types feature specification #3182
Conversation
It includes the special case of the primary constructor syntax, and it makes this syntax required (it's a syntax error to not have it). It allows non-extension-type superinterfaces as long as they are supertypes of the representation type. As a thought experiment (which we could take seriously), it does not make the representation name available as a getter. This means that the representation object is treated, as we've mentioned in various discussions, as a name which is in scope in the extension type body but not accessible from anywhere else (just like type parameters). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I think this proposal would be much less confusing to users than the inline classes proposal. In particular I think the semantics of both redeclaration and fields are far less surprising.
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
…is to receive the representation object as an actual argument to the constructor
…es not allow that
… the outside (in other words: drop the lexical-only-access exception)
Just landed a commit that drops the special exception whereby |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got to line 915.
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
accepted/future-releases/extension-types/feature-specification.md
Outdated
Show resolved
Hide resolved
Author: eernst@google.com | ||
|
||
Status: Accepted. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we start with a motivating example, similar to https://github.com/dart-lang/language/blob/main/accepted/future-releases/inline-classes/feature-specification.md#motivation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm slighlty split here. Motivating examples are nice for getting things accepted, but once accepted, I'd like a tight, sharp specification the of what the feature does, without motivation or discussions about alternatives. Just the facts.
Could we split it in two files? Motivation/discussion and specification. If the specification doesn't work without the other text, then it's already non self-contained enough.
Great feedback, @lrhn! Changed a bunch of things and uploaded. |
…dynamic); what it means to "have" (non-)extension type members; add errors (incl implements T); cleaned up duplicated error messages
Further revisions have been made now. In particular, a lot of things became simpler by introducing the notion of 'an extension type member' and 'a non-extension type member' maintains the distinction that the declaration of the given member is located in an extension type declaration respectively it is in the interface of a non-extension type superinterface. So we don't need to re-explain that we need to look up through the superinterface graph in order to see whether any given member came from an extension type or from a non-extension type. |
…stant if there is an explicit `const`, otherwise not
Just updated the grammar to support |
Modify the inline class feature specification to specify extension types. This is a feature renaming, but also a reintroduction of a special case of the primary constructor syntax, and an enhancement with support for non-extension type superinterfaces (cf. #3090). Note that many types cannot be used as superinterfaces (including `Function` and function types, records, `T?` for any `T`); we may choose to enable a broader set of types in the future, but at this time we prefer to keep it simple. For instance, `UP` may need to be revised if we accept a broader set of types.
This PR is a proposal for how we could specify extension types, following up on the discussions it the language team this week.
cc @dart-lang/language-team