-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Bad bytecode generated for a partial function. #2396
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
Comments
Reproduced. Looking into it. |
A simpler version of this issue is: class Bees {
import Test._
def f: PartialFunction[Bee, Unit] = {
case Test.Bee(_) => ""
// case Bee(_) => "" // This one works
}
f(new Bee("buzz"))
}
object Test {
case class Bee(value: String)
def main(args: Array[String]): Unit = new Bees
} Note that the issue seems to come from the prefix |
A simpler case that exhibits a similar issue is: class Bees {
def f: PartialFunction[Bee, Unit] = { case Bee(_) => "" }
f(new Bee("buzz"))
case class Bee(value: String)
// object Bee // With this it works
}
object Test {
def main(args: Array[String]): Unit = {
new Bees
}
} fails with Caused by: java.lang.NullPointerException
at Bees.Bees$f$$f$$anonfun$1$1(i2396.scala:6)
at Bees$$anonfun$1.apply(i2396.scala:6)
at Bees$$anonfun$1.apply(i2396.scala:6)
at Bees.<init>(i2396.scala:9)
at Test$.main(i2396.scala:17)
at Test.main(i2396.scala) where the bytecode has public class Bees {
public final Bees.Bee$ Bee$lzy1;
public Bees() {
this.f().apply(new Bees.Bee(this, "buzz"));
this.Bee$lzy1 = new Bees.Bee$(this); // should be lazy
}
public final Bees.Bee$ Bee() { return this.Bee$lzy1; } // should be initialized in here if needed
...
} Issue #2454 |
@nicolasstucki, the issue you've triggered seems like a different issue. |
I will create another issue for it. |
This is a bug in ElimStaticThis, that was creating references to packages. See
|
Fixes available for both problems. |
Fix #2396: don't create refernces to packages in ElimStaticThis
When running the example below, it fails with
java.lang.VerifyError
Full stack traceReproducible in fresh
lampepfl/dotty.g8
OpenJDK 8 on Ubuntu
The text was updated successfully, but these errors were encountered: