I need to write a generic trait, which can return the class of its generic type. Here is what I am trying to implement, but I can't get it to compile:
trait MyTrait[T] {
implicit def classTagT: ClassTag[T]
def foo(t: T): Unit
def getType(): Class[T] = classTagT.runtimeClass
}
What is the best way to accomplish this? Should I be writing a macro instead?
Aucun commentaire:
Enregistrer un commentaire