Skip to content
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

Backport "Add clause for protected visibility from package objects" #18148

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

Kordyjan
Copy link
Contributor

@Kordyjan Kordyjan commented Jul 5, 2023

Backports #18134
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.
@Kordyjan Kordyjan requested a review from odersky July 5, 2023 10:58
@Kordyjan Kordyjan added this to the 3.3.1 milestone Jul 5, 2023
@Kordyjan Kordyjan enabled auto-merge July 5, 2023 10:59
@Kordyjan Kordyjan mentioned this pull request Jul 5, 2023
13 tasks
@Kordyjan Kordyjan merged commit e5c3f2d into scala:release-3.3.1 Jul 5, 2023
17 checks passed
@Kordyjan Kordyjan deleted the backport-18134 branch July 5, 2023 15:51
@odersky odersky assigned Kordyjan and unassigned odersky Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants