-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Dotty generates code that cause Exception in thread "main" java.lang.IllegalAccessError during runtime. #13897
Comments
This is the decompiled bytecode 2.13.6
3.1.0
So 2.13.6 does an extra |
We need a version that does not have the dependency |
I managed to minimize it. Bar.java package com.a.b;
public class Bar<V> {
abstract static class BuilderImpl<V, B extends BuilderImpl<V, B>> {
public B call() {
return (B) this;
}
}
} Baz.java package com.a.b;
public final class Baz extends Bar<String> {
public static final class Builder extends Bar.BuilderImpl<String, Builder> {}
} Main.scala package bugreport
import com.a.b.Baz
object Main {
def main(args: Array[String]): Unit = {
val b = new Baz.Builder()
b.call() // works
val x = b.call(); val y = x.call() // also works
b.call().call() // works on 2.13, fails on Scala 3
}
} edit: shrunk it further |
Possibly duplicates #13841 like two ships passing in the night. |
Closing this as duplicate. |
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.
Compiler version
All versions of Dotty seem to be affected.
Java 8 and 11, possibly newer ones as well.
Minimized code
build.sbt
Program
Output
Compilation succeeds. Fails at runtime with
Expectation
Should work as in 2.13.6
The text was updated successfully, but these errors were encountered: