Skip to content

getClass on Unit not erased properly #5568

@scabug

Description

@scabug

You shouldn't be able to cast your way to a VerifyError.

object Test {
  final val UNIT: AnyRef with Unit = ().asInstanceOf[AnyRef with Unit]
  
  def main(args: Array[String]): Unit = {
    println(UNIT.getClass)
  }
}
% scala Test
java.lang.VerifyError: (class: Test$, method: main signature: ([Ljava/lang/String;)V) Incompatible object argument for function call
	at Test.main(a.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions