Closed
Description
scala> def test[A]: List[Int] | A => Int = { case ls: List[Int] => ls.head case _ => 0 }
def test[A] => List[Int] | A => Int
scala> test(List("oops"))
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:103)
The definition of test
should at least yield a warning like "erased type argument Int
in type pattern List[Int]
is unchecked".