scala> val tpeList = typeOf[List[_]]
tpeList: reflect.runtime.universe.Type = scala.List[_]
scala> appliedType(tpeList, List(typeOf[Int]))
res0: reflect.runtime.universe.Type = scala.List[Int]
Scala Macros: How to get a Type object of a generic List
-
28-09-2022 - |
문제
I'm working on a Scala macro where I want to match the type of a Symbol
to a List[T]
, where the T
is a given Type
. I have the Type
object of the T
type parameter already.
It's easy to get the Type object of List[_]
:
val listType = c.weakTypeOf[List[_]]
with this I can already check the typeSignature
sourceParam.typeSignature match {
case paramType if paramType <:< listType =>
....
}
But I want to check paramType with List[T]
, so how do I make a Type where I take the List[_]
and some Type
object and make it a new Type?
해결책
제휴하지 않습니다 StackOverflow