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

Fixes IllegalAccessError with Java package protected class #21362

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

eed3si9n
Copy link
Member

This is a backport of Scala 2.x scala/scala#6023 by @lrytz

Fixes #13841
Fixes #13897

Problem

When compiling builder.call1().call2() where both are Java-defined package-protected class through a public subsclass, Scala 3 does not properly cast the receiver to the public class, and results in an IllegalAccessError.

Solution

This backports the casting fix from the Scala 2.x compiler.

This is a backport of Scala 2.x scala/scala 6023
Fixes 13841
Fixes 13897

**Problem**
When compiling `builder.call1().call2()` where both are Java-defined
package-protected class through a public subsclass, Scala 3 does not properly
cast the receiver to the public class, and results in an IllegalAccessError.

**Solution**
This backports the casting fix from the Scala 2.x compiler.
Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

LGTM

I was recently in the area (in Scala 2) for scala/scala#10794.

Though I wrote in the corresponding ticket (scala/bug#13007) "Scala 3 rejects the above example", this doesn't seem to be the case now. I'll create a new scala3 ticket for that.

@lrytz
Copy link
Member

lrytz commented Aug 12, 2024

this doesn't seem to be the case now. I'll create a new scala3 ticket for that.

Actually the Scala 3 behavior for the example I tried is is correct, so maybe there's nothing to do for Scala 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants