I have some code like this:
class ReflectiveJsonFormat[T:TypeTag] extends JsonFormat[T] {
def write(x: T) : JsValue = {
val t = typeOf[T]
val getters = t.declarations.filter { s => s.isMethod && s.asMethod.isGetter }
val mirror = runtimeMirror(this.getClass.getClassLoader)
val instanceMiror = mirror.reflect(x)
}
}
That last line fails with:
No ClassTag available for T
I thought TypeTag
was more info than a ClassTag
? Can I get the ClassTag
from the TypeTag
? If not, is there some syntax for saying that T
has two context bounds -- both TypeTag
and ClassTag
? Or, how would you otherwise fix this code?