-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[SUPERSEDED] Inherited members have same binding level as package level [ci: last-only] #8839
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
Conversation
As with names introduced by package statements, base classes can introduce definitions that shadow local definitions and import statements. Let inherited members have the same name-binding precedence as package-level definitions: highest when defined in the current compilation unit, and lowest otherwise. This means that a base class defined elsewhere cannot introduce a name that shadows a local definition. The inherited name can be referred to unambiguously using `this`; a conflicting local variable or parameter must be renamed or aliased; a conflicting member using a `C.this` prefix.
(Can't |
The problem is that this way inherited members also cause ambiguities local imports which is too strict, IMO. |
Sample confusing thing:
which Here For purposes of naming, it's not obvious that a conflicting definition somewhere in The proposed precedence rule makes it harder to write a "grab-bag" import; Java calls it "on-demand". |
@dwijnand it seems to respect last-only, whew. I wasn't prepared to squash yet. Some people sit at home sewing surgical masks during quarantine. The experience here was similar to updating the implementation previously to spec: the troublesome code was hard to read (scaladoc packagings). I thought the cross-talk with "Root" imports don't import
Anyway, this implementation isn't quite correct; I'll take a second look to see if it's worth a third look. |
Yeah. I guess it's per-push. I think this is right: if you open a PR with 10 commits and then edit the title, then it will still consider all 10 commits combined; but if you push again then it switches to last only. |
I'll resubmit this for the next pandemic. |
It's still lockdown. |
Closing for pandemic. |
The superseding linked PR attempts to follow Scala 3 semantics. |
As with names introduced by package statements, base classes
can introduce definitions that shadow local definitions and
import statements.
Let inherited members have the same name-binding precedence
as package-level definitions: highest when defined in the current
compilation unit, and lowest otherwise. This means that a base
class defined elsewhere cannot introduce a name that shadows a
local definition.
The inherited name can be referred to unambiguously using
this
;a conflicting local variable or parameter must be renamed or
aliased; a conflicting member using a
C.this
prefix.Fixes scala/bug#11921