Вопрос

I'm trying to get the parameterized type of a member on a symbol in a MACRO context. I only have a symbol available (can't use weakTypeOf[List[Blah]]) because I am iterating over a bunch of classes.

val meWantArg = classSymbol.member("paramList": TermName).typeSignature

returns...

=> List[IWantThis]

How do I get IWantThis Type object???

I've tried:

meWantArg.typeSymbol.asType.typeParams //returns List(type A)

I've tried extraction:

TypeRef(_,_,args) = meWantArg //returns ()

Keep in mind, I am using the 2.10.2 macro plugin.

Это было полезно?

Решение

I am guessing from => IWantThis that paramList is not a val but an arity-0 method without parentheses:

def paramList: List[IWantThis] = ???

If so, the member is a method type, and you have to get the return type of the method before extracting arguments from it:

val meWantArg = classSymbol.member("paramList": TermName).asMethod.returnType
val TypeRef(_,_,args) = meWantArg
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top