null.asInstanceOf[T] where T is a value type results in NullPointerException #8097
Open
Description
While the direct route of
case class Foo(d: Double) extends AnyVal
null.asInstanceOf[Foo]
was fixed in #5866, the issue remains when Generics get involved:
scala> case class Foo(d: Double) extends AnyVal
defined class Foo
scala> def newInst[T] = null.asInstanceOf[T]
newInst: [T]=> T
scala> newInst[Foo]
java.lang.NullPointerException
... 32 elided