-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Declaration order confuses CFE's notion of sealed when mixins involved #52048
Comments
If this is just restricted to mixing in things onto a sealed class (why do we even have that lever?) I think I'm on the fence about cherry picking, it doesn't feel likely to be a widespread problem. Definitely worth fixing though, and we can then consider. Separately, the error message there is pretty terrible. |
I guess our intuitions disagree about how useful it is to do that. That's fine--to each their own. But for what it's worth, I didn't find this bug by deliberately poking at edge cases. I found it because I was trying out patterns in a side project over the weekend, and it arose naturally from a genuine attempt to write a useful program 😃 (The details of what I was trying to do, if you're curious: I had a sealed class with several derived classes, and I had a mixin (in a different library) that I could use to add some extra debugging functionality to a class. I wanted to add the extra debugging functionality to some of the derived classes but not all of them. I was using the standard "sort declarations" feature in the IDE to keep my file organized, and so I happened to hit on the sort order that provoked the bug.) |
Since Kallen is on vacation this week, I'll look into this. |
This should fix it: https://dart-review.googlesource.com/c/sdk/+/297901 |
…kSupertypes phase. Previously this step happened during `buildOutlineNodes`, but since `buildOutlineNodes` happens in source order, this means that anonymous mixins would only get their sealed and final attributes properly inferred if they appeared *after* their immediate supertypes in source order. By moving this step to `checkSupertypes`, we ensure that the computation is correct regardless of source order, because `checkSupertypes` happens in class hierarchy order. Fixes: #52169. Bug: #52048 Change-Id: Ife69b582d53fcd49be87a570cd969389a58689e4 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/297901 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298200 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
The following program is accepted by both the CFE and the analyzer:
However, if you swap the order of declaration of classes
A
andB
, i.e.:Then you get the following error from the CFE:
Reproduced as of 90d84c8.
If we can fix this before the release, I suspect it will be worth cherry-picking to stable.
CC @johnniwinther
The text was updated successfully, but these errors were encountered: