如何解析给定的别名
Type
? 即。
import reflect.runtime.universe._
type Alias[A] = Option[Option[A]]
val tpe = typeOf[Alias[_]]
val ExistentialType(quantified, underlying) = tpe
我怎么得到
Option[Option[_$1]]
从…起
underlying
(或来自
tpe
)? 我知道
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)