object Test {
def main(args: Array[String]) {
val list: List[Double] = List(1.0, 2.0, 3.0, 4.0)
val none = None
case class Test()
val test = Test()
def f(x: Any) = x match {
case _: Some[Test] => println("_ matched")
case None => println("None matched")
}
f(list)
f(none)
f(test)
}
}
Trying to compile the above code leads to an "eliminated by erasure" compile-time warning.
$>scalac Test.scala
Test.scala:11: warning: non-variable type argument Test in type pattern
Some[Test] is unchecked since it is eliminated by erasure
case _: Some[Test] => println("_ matched")
^
one warning found
I read this highly regarded Stackoverflow post, but I don't understand the type erasure here.