Как получить псевдоним типа псевдонима типа во время выполнения scala?

import scala.reflect.runtime.universe._

object Main {

  final type INeedDetails = (Int, String, Unit, Nothing, Float)

  def main(args: Array[String]): Unit = println {
    typeTag[INeedDetails]
  }

}

В приведенном выше фрагменте будет указано TypeTag[Main.INeedDetails]. Есть ли способ извлечь полную информацию о кортеже (Int, String, Unit, Nothing, Float) из этого TypeTag?


person Prikso NAI    schedule 08.11.2017    source источник


Ответы (1)


Вы можете dealias тип из тега:

scala> type INeedDetails = (Int, String, Unit, Nothing, Float)
defined type alias INeedDetails

scala> typeTag[INeedDetails].tpe
res1: reflect.runtime.universe.Type = INeedDetails

scala> typeTag[INeedDetails].tpe.dealias
res2: reflect.runtime.universe.Type = (scala.Int, String, scala.Unit, scala.Nothing, scala.Float)
person Kolmar    schedule 08.11.2017