-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enclosing package p.q not visible as q #23069
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
base: main
Are you sure you want to change the base?
Conversation
fca2ca4
to
05fc3cd
Compare
It's been a while since I ran the lint on the dotty code base. |
end if | ||
done = true | ||
else | ||
return // found enclosing definition, don't register the reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This special handling isn't necessary. Just set a flag for "found enclosing" (so don't register reference), then in outer context it will find the member (for "simple package" or other defs) and not find the "hidden" dotted package name. The latter case won't terminate right away (but that could be fixed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I already told tpolecat that I deleted the return
.
05fc3cd
to
bea7edc
Compare
@@ -419,7 +419,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha | |||
candidate = cur | |||
importer = sel | |||
else if checkMember(cur.owner) then | |||
if sym.srcPos.sourcePos.source == ctx.source then | |||
if sym.is(Package) || sym.srcPos.sourcePos.source == ctx.source then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package sym has no source to compare.
bea7edc
to
06d1611
Compare
Fixes #23047
Normally, an enclosing definition always has higher "name binding" precedence than an import, but an enclosing packaging can have a dotted name with a simple name that can't be referenced without qualification or import.
This first cut gives up, but we can infer whether a package was introduced with a dotted name by comparing the owner of the current context with the enclosing package owner.
The second commit does that clever thing (which is not necessarily a good thing).