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

Commits on Jul 5, 2023

  1. Add clause for protected visibility from package objects

    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.
    odersky authored and Kordyjan committed Jul 5, 2023
    Configuration menu
    Copy the full SHA
    aed47fd View commit details
    Browse the repository at this point in the history