【发布时间】:2015-03-29 03:17:30
【问题描述】:
如何解决给定Type 的别名?即
import reflect.runtime.universe._
type Alias[A] = Option[Option[A]]
val tpe = typeOf[Alias[_]]
val ExistentialType(quantified, underlying) = tpe
如何从underlying(或tpe)获得Option[Option[_$1]]?我知道typeSymbol确实解析了别名,但是在这个过程中好像丢失了参数:
scala> val tT = typeOf[Alias[_]].typeSymbol
tT: reflect.runtime.universe.Symbol = class Option
scala> tT.asType.toType
res3: reflect.runtime.universe.Type = Option[A]
scala> tT.asType.typeParams
res4: List[reflect.runtime.universe.Symbol] = List(type A)
【问题讨论】:
标签: scala reflection scala-reflect