È possibile ottenere uno Type
da un TypeTag[A]
utilizzando il metodo tpe
. Ma posso anche recuperare il tag di tipo da un tipo?Ottieni un TypeTag da un tipo?
import scala.reflect.runtime.{universe => ru}
import ru.{Type, TypeTag}
def forward[A](implicit tt: TypeTag[A]): Type = tt.tpe
def backward(t: Type): TypeTag[_] = ???
Il motivo è che ho un'API che utilizza tipo-tag come chiavi in una mappa, ma ad un certo punto ho solo il tipo e lasciò cadere il tag.
rilevanti, eventualmente duplicate: http://stackoverflow.com/questions/11494788/how-to-create-a-typetag-manually –
api cambiato ora - in modo da poter passare l'implementazione di 'TypeCreator' invece di' TypeFactory' – dk14