-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes IllegalAccessError with Java package protected class
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.
- Loading branch information
Showing
4 changed files
with
59 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// filter: unchecked | ||
package a; | ||
|
||
class B<T extends B<T>> { | ||
private int connectTimeout = 10000; | ||
private int failedAttempts = 3; | ||
|
||
public T setConnectTimeout(int connectTimeout) { | ||
this.connectTimeout = connectTimeout; | ||
return (T) this; | ||
} | ||
|
||
public T setFailedAttempts(int failedAttempts) { | ||
this.failedAttempts = failedAttempts; | ||
return (T) this; | ||
} | ||
} | ||
public class A extends B<A> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package b | ||
|
||
import a.* | ||
|
||
object C: | ||
def m: Int = | ||
val a = new A() | ||
.setConnectTimeout(1) | ||
.setFailedAttempts(1) | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object Test extends App: | ||
assert(b.C.m == 0) | ||
end Test |