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
@dwijnand dwijnand requested a review from eed3si9n 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.
@dwijnand dwijnand force-pushed the protected-sep-comp-java branch from 8b8d3bf to 17dadf7 Compare October 30, 2024 15:31
@@ -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
@dwijnand dwijnand force-pushed the protected-sep-comp-java branch from 282f8d3 to 350215d Compare October 31, 2024 19:22
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
WojciechMazur added a commit that referenced this pull request Nov 8, 2024
Backports #21857 to the 3.6.2 branch.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added backport:done This PR was successfully backported. and removed backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. labels Nov 8, 2024
@WojciechMazur WojciechMazur added this to the 3.6.2 milestone Nov 8, 2024
WojciechMazur added a commit that referenced this pull request Dec 4, 2024
Backports #21857 to the 3.3.5.

PR submitted by the release tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:done This PR was successfully backported.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to extend protected nested class
4 participants