-
Notifications
You must be signed in to change notification settings - Fork 21
deprecate nested "overriding" classes with same name #8353
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8353?orig=1 |
@soc said: |
@adriaanm said: |
This came up today on Gitter, where people wondered if Dotty might change things back.
Does anybody know the rationale for that? On Gitter @nafg mentioned the (IMHO most useful) use case:
which is the only one I've seen used (in the Scala collection views, for encoding virtual classes). |
Martin mentioned last week that this restriction is no longer in dotty, so we can close this ticket. |
Can I suggest reopening until Dotty actually lifts the restriction and removes http://dotty.epfl.ch/docs/reference/dropped/class-shadowing.html? On latest master (scala/scala3@8feb596):
EDIT: opening a dotty issue for this. |
Yes, let's see if it really happens :) |
BTW, the current Dotty docs do give a rationale (which is the most well-known problem):
I suspect we'd want to warn in Scala2 mode and restrict to overrides in Scala3 mode? But given the amount of code impacted, I'd like some non-completely-ad-hoc policy for making these language changes. These seem enough questions to reopen this. EDIT1: Whoops had missed Lukas comment! EDIT2: Dotty seems close to supporting shadowing, but supporting actual overriding is less trivial — if I disable checks stupidly, shadowing works but overriding gives cyclic reference errors. |
Just realized that shadowing still seems inherently unsound unless the shadowing class in fact inherits from the superclass, per example |
FYI: I've re-closed the Dotty issue for now, since Martin went back (more than a month ago) to the original plan of disallowing shadowing. |
volunteer to do the deprecation? |
Fixes scala/bug#8353 Fixes scala/bug#11360 This deprecates nested class shadowing for Dotty compatibilty.
Did anyone say deprecation? - scala/scala#8705 |
Fixes scala/bug#8353 Fixes scala/bug#11360 This deprecates nested class shadowing for Dotty compatibilty.
Fixes scala/bug#8353 Fixes scala/bug#11360 This deprecates nested class shadowing for Dotty compatibilty.
Fixes scala/bug#8353 This deprecates nested class shadowing in "override" position for Dotty compatibilty. In general Scala does not implement override of classes where "new Status" might take on different meaning based on what the subtypes are doing. To avoid the confusion, we are deprecating the nested class shadow another nested class if it was introduced by a parent class.
Fixes scala/bug#8353 This deprecates nested class shadowing in "override" position for Dotty compatibility. In general Scala does not implement override of classes where "new Status" might take on different meaning based on what the subtypes are doing. To avoid the confusion, we are deprecating the nested class shadow another nested class if it was introduced by a parent class.
This PR causes a false class shadowing warning. |
Martin says:
instead of:
write:
The text was updated successfully, but these errors were encountered: