-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] Disambiguate extension type
to declare an extension type
#53883
Comments
cc @itsjustkevin @Hixie @vsmenon I'd like to expedite review on this since it's on the critical path for release. This is a small technical breaking change which I don't expect to break anything in practice. |
@grouma could you weigh in on this breaking change as well? |
lgtm |
SGTM. |
Move the intersection type rules up in the definition of `UP`, such that no results are of the form `(X & B)?`. The point is that types of the form `(X & B)?` are not intended to occur at all, and this change will ensure that `UP` will not create any such type. For further information, see: - Implementation: https://dart-review.googlesource.com/c/sdk/+/333922 - Breaking change request: dart-lang/sdk#53883
i strongly support this |
Very good, thanks! The behavior has been implemented already, so there will not be a separate 'implementation' issue, I'll put the 'implementation' link here such that it is documented that the implementation has been handled. |
@sgrekhov, I believe we also have co19 tests for this topic, right? |
For extension we have I'll add this corner case with record type as well |
Change Intent
The Dart grammar currently allows
extension type on (int i,) {}
as a declaration of anextension
whose name istype
and whose on-type is a record type.With the upcoming introduction of extension type declarations, the language team wishes to ensure that it cannot be an
extension
, such that a reader of Dart code can safely assume that a declaration starting withextension type
will be anextension type
declaration.The change proposed here is an adjustment of the grammar such that this goal is achieved. Details here: dart-lang/language#3431.
Justification
The introduction of extension type declarations creates an ambiguity, and it must be resolved. The language team prefers to ensure that a declaration that starts with
extension type
actually declares an extension type and not a plain extension, because that is considered to be the least surprising choice. Also, the value of being able to have anextension
whose name istype
is considered low.Impact
Probably very low: It only affects
extension
declarations whose name istype
, and that choice of name violates the general rule that type-like entities should have a capitalized name.Mitigation
Rename the extension named
type
to some other name. This will affect explicitly resolved extension member invocations (wheretype
must be replaced by the new name). It is expected to be a very rare phenomenon: Extensions namedtype
are presumably very rare, and only few extension member invocations are resolved explicitly: Low probability times low probability is even lower probability.Change Timeline
As soon as possible. This ambiguity will have to be handled at some point anyway.
Associated CLs
None, yet.
The text was updated successfully, but these errors were encountered: