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

Fix extending protected nested java classes #21857

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dwijnand
Copy link
Member

Fixes #21631

@dwijnand dwijnand marked this pull request as ready for review October 29, 2024 21:33
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

PR 21362 added an accessibility fix to Erasure, but that revealed a
mistake in determining the accessibility of inner java classes, which
I'm now fixing.
@@ -401,7 +401,8 @@ class ClassfileParser(
classRoot.setFlag(sflags)
moduleRoot.setFlag(Flags.JavaDefined | Flags.ModuleClassCreationFlags)

val privateWithin = getPrivateWithin(jflags)
val jflags1 = innerClasses.get(currentClassName.toString).fold(jflags: Int)(_.jflags)
val privateWithin = getPrivateWithin(jflags1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scala 2 sets the privateWithin for inner classes when creating the symbol in enterOwnInnerClasses

https://github.com/scala/scala/blob/v2.13.15/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala#L1055-L1058

Maybe Scala 3 should also do it there?

@dwijnand dwijnand requested a review from lrytz October 31, 2024 18:44
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.

Unable to extend protected nested class
3 participants