I need to do a pattern match on Classes. The Problem is, that I have some Problems matching a Long.
I need to handle scala.Long and java.lang.Long in the same way, but why do I need to declare them both in cases?
Here is an example:
def test(typ: Class[_]) {
typ match {
case q if q == classOf[Long] => println("scala long...")
}
}
val scalaLongField: java.reflect.Field = ......
val javaLongField: java.reflect.Field = ......
test(scalaLongField.getType) // prints "scala long..."
test(javaLongField.getType) // scala.MatchError: class java.lang.Long (of class java.lang.Class)
Is there a way to handle them the same without having an instance but just the class?