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

Merged
merged 3 commits into from
Nov 6, 2024

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
new ClassfileLoader(file),
classTranslation.flags(jflags),
getScope(jflags))

val privateWithin = getPrivateWithin(jflags)
Copy link
Member

Choose a reason for hiding this comment

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

if privateWithin.exists then here as well for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

@dwijnand dwijnand merged commit 32aaa8a into scala:main Nov 6, 2024
29 checks passed
@dwijnand dwijnand deleted the protected-sep-comp-java branch November 6, 2024 12:11
@WojciechMazur WojciechMazur added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to extend protected nested class
4 participants