-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add clause for protected visibility from package objects #18134
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes #18124 |
We usually have an access rule that the access to a protected member `foo` in class `C` must be from somewhere nested in a subclass of `C`. But that fails if the member is accessed from a package object `p.package`. In that case, the access does not need to be in the same object, it just has to be in package `p`. This clause was previously missing and is now added. Why was this only recently discovered? scala#18057 fixed an issue where toplevel protected members were always accessible because explicit package object prefixes were added after the accessibility check was done, and would re-establish the previous members without doing an accessibility check. The fix was done by adding package objects first, then doing he rest of the checks. But that also means that protected toplevel objects now get checked as members of their synthetic package object instead of as members of their package. The change here also makes specs2 compile again.
dwijnand
approved these changes
Jul 5, 2023
odersky
added
the
backport:nominated
If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
label
Jul 5, 2023
odersky
changed the title
Make toplevel protected qualified protected
@odersky Add clause for protected visibility from package objects
Jul 5, 2023
odersky
changed the title
@odersky Add clause for protected visibility from package objects
Add clause for protected visibility from package objects
Jul 5, 2023
I will release RC3 as soon as this pr is merged then. |
Kordyjan
added
backport:accepted
This PR needs to be backported, once it's been backported replace this tag by "backport:done"
and removed
backport:nominated
If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
labels
Jul 5, 2023
Kordyjan
added a commit
that referenced
this pull request
Jul 5, 2023
Kordyjan
added
backport:done
This PR was successfully backported.
and removed
backport:accepted
This PR needs to be backported, once it's been backported replace this tag by "backport:done"
labels
Aug 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We usually have an access rule that the access to a protected member
foo
in classC
must be from somewhere nested in a subclass of
C
. But that fails if the member isaccessed from a package object
p.package
. In that case, the access does not need to be inthe same object, it just has to be in package
p
. This clause was previously missingand is now added.
Why was this only recently discovered?
#18057 fixed an issue where toplevel protected members were always accessible
because explicit package object prefixes were added after the accessibility check was done,
and would re-establish the previous members without doing an accessibility check. The fix was
done by adding package objects first, then doing he rest of the checks. But that also means
that protected toplevel objects now get checked as members of their synthetic package object
instead of as members of their package.
The change here also makes specs2 compile again.