Skip to content

java.lang.VerifyError: Bad type on operand stack #12557

Closed
@xuwei-k

Description

@xuwei-k

Compiler version

3.0.1-RC1-bin-20210521-de319fb-NIGHTLY and 3.0.0

Minimized code

package example

abstract class X[P <: Product](using val m: scala.deriving.Mirror.ProductOf[P]) {
  def unapply(p: P): m.MirroredElemTypes = ???
}

case class A(a: Int)
object A extends X[A]

object Main {
  def main(args: Array[String]): Unit = {
    A.unapply(A(2))
  }
}

Output

[info] running example.Main 
[error] (run-main-7) java.lang.VerifyError: Bad type on operand stack
[error] Exception Details:
[error]   Location:
[error]     example/A$.<init>()V @2: invokevirtual
[error]   Reason:
[error]     Type uninitializedThis (current frame, stack[1]) is not assignable to 'example/A$'
[error]   Current Frame:
[error]     bci: @2
[error]     flags: { flagThisUninit }
[error]     locals: { uninitializedThis }
[error]     stack: { uninitializedThis, uninitializedThis }
[error]   Bytecode:
[error]     0x0000000: 2a2a b600 15b7 0018 b1                 
[error] java.lang.VerifyError: Bad type on operand stack
[error] Exception Details:
[error]   Location:
[error]     example/A$.<init>()V @2: invokevirtual
[error]   Reason:
[error]     Type uninitializedThis (current frame, stack[1]) is not assignable to 'example/A$'
[error]   Current Frame:
[error]     bci: @2
[error]     flags: { flagThisUninit }
[error]     locals: { uninitializedThis }
[error]     stack: { uninitializedThis, uninitializedThis }
[error]   Bytecode:
[error]     0x0000000: 2a2a b600 15b7 0018 b1                 
[error] 
[error] 	at example.Main$.main(A.scala:11)
[error] 	at example.Main.main(A.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] Nonzero exit code: 1
[error] (Compile / run) Nonzero exit code: 1

Expectation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions