vendredi 24 juillet 2015

Get generic types of child in scala 2.10

class Parent[T: ClassTag] {
}

class Child[U: ClassTag, T: ClassTag] extends Parent[T] {
}

val o: Parent[_] = new Child[Int, String]

Is it possible to get the actual types of T and U given o (note its type Parent[_]), assuming you know o is of type Child?

I have tried a few things based on Runtime resolution of type arguments using scala 2.10 reflection but no luck so far.





Aucun commentaire:

Enregistrer un commentaire