-
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] Specify that a method shadows an "inherited" setter, and vice versa #3470
Conversation
… they do not have any special kind of shadowing
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
I think the text has been clarified substantially, PTAL. |
Thanks! |
@johnniwinther, this spec change is being implemented in the analyzer as tracked by dart-lang/sdk#53719 and done in https://dart-review.googlesource.com/c/sdk/+/337641. Is there a need for an implementation issue and an implementation effort for the CFE as well, or is this already on track? Just a quick check: The current version of the CFE (2534859b418898024576014b2ca99d379c3ccc3a) does not seem to have been updated to use the new 'precludes' rule, it still reports the method/setter conflicts. |
@johnniwinther, I just learned that the CFE implementation issue for this task could be dart-lang/sdk#53720 (OK, I forgot about that and then rediscovered it ;-). I added a comment there about the fact that the specification changed, and hence the issue is about implementing 'precludes' as specified in this PR, not about changing a confusing CFE error message. |
See dart-lang/language#3470 Bug: #53719 Change-Id: Iab840870a4d5be18a591f8fcef81bacb4a5d22cc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337641 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
Adjust the rules about extension type member conflicts: precluded members do not create conflicts. This PR changes the rule about member conflicts such that a member which is precluded does not conflict with any other members. It is an adjustment of the rules added by #3470. For example, if an extension type `E1` declares a method named `m` and an extension type `E2` declares a setter named `m=` and has `implements E1`, then `E2` does not "inherit" the method named `m` (it is precluded because it would conflict with the setter). In this PR we add an extra rule which says that it is not a conflict if `E2` has two superinterfaces `E1a` and `E1b`, and `E1a` declares a method named `m` and `E1b` declares a getter named `m`, and `E2` again declares a setter named `m=` and has `implements E1a, E1b`. The point as that `E2` will "inherit" the getter (so it has a full setter/getter pair), but not the method (because it is precluded by the setter), and (here comes the new thing) the method is ignored during conflict checks because it is precluded, so we avoid the useless error about `m` being ambiguous that we'd otherwise have because of `implements E1a, E1b`.
Background: See dart-lang/sdk#53717, dart-lang/sdk#53719, dart-lang/sdk#53720.
This PR changes the extension types feature specification such that a method declaration in an extension type will shadow an "inherited" setter, and vice versa. This eliminates a setter/method conflict which couldn't otherwise be resolved.
For example:
This PR has been accepted, so we need to reconsider dart-lang/sdk#53717 and its subtasks. They have been repurposed to get this spec change implemented: