I have two very similar methods. The only difference is the use of ClassTag
and TypeTag
:
def matchClass[A: ClassTag](v: Any) =
v match {
case a: A => "it's A"
case _ => "not A"
}
def matchType[A: TypeTag](v: Any) = ... // same code as matchClass
A compile warning will show for matchType
, but not for matchClass
:
abstract type pattern A is unchecked since it is eliminated by erasure case a: A
Why is there a warning? why does it show only for TypeTag
and not ClassTag
?
Aucun commentaire:
Enregistrer un commentaire