Closed
Description
minimized code
class UnitClass(val x: Unit)
object Test {
def main(args: Array[String]): Unit = {
println(new UnitClass(()))
}
}
Compiles but fails at runtime
Exception in thread "main" java.lang.NoSuchFieldError: UnitClass.x
at UnitClass.<init>(Test.scala:1)
at Test$.main(Test.scala:5)
at Test.main(Test.scala)
expectation
It works fine on Scala 2. It also works fine if you change the Unit
to e.g. Int
or String
.