If you want a fairly literal translation from manifests to type tags, you'll need to get the appropriate mirror, use it to reflect your instance, and then use the <:<
on Type
. For example:
import scala.reflect.runtime.currentMirror
import scala.reflect.runtime.universe._
sealed trait X
case class Y(i: Int) extends X
case class Z(j: String) extends X
def filterX[A <: X: TypeTag](xs: List[X]) = xs.filter(
x => currentMirror.reflect(x).symbol.toType <:< typeOf[A]
)
And now:
scala> filterX[Z](List(Y(1), Y(2), Z("test")))
res1: List[X] = List(Z(test))
scala> filterX[Y](List(Y(1), Y(2), Z("test")))
res2: List[X] = List(Y(1), Y(2))
There may be ways you could take advantage of the new Reflection API more fully in your application, but this should work and will take care of the deprecation warnings.