Found how to obtain typeTag for least common supertype. But how to capture typetag\'s generic into type alias to operate type itself?
Assuming TypeTag[SomeType
This will work if typeTag's generic was not erased (enough for extracting common supertype of types, that are known at compilation time):
class TypeHolder { type T }
object TypeHolder {
def apply[U](a: TypeTag[U]) = new TypeHolder{type T = U}
}
Usage:
val typ = TypeHolder(typeTag[Int])
val k: typ.T = 5
val list = List[typ.T]()
trait A { def aaaa: typ.T }
someObject.isInstanceOf[typ.T]
But you can't do it with type variable because it will be "erased" to Any