Skip to content

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.

@eed3si9n eed3si9n merged commit 8e9ded0 into scala:main Sep 12, 2024
28 checks passed
@eed3si9n eed3si9n deleted the wip/t10450 branch September 12, 2024 18:34
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
WojciechMazur added a commit that referenced this pull request Dec 4, 2024
… to LTS (#22123)

Backports #21362 to the 3.3.5.

PR submitted by the release tooling.
[skip ci]
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