2

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.

4

1 回答 1

3

我猜=> IWantThisparamList不是一个val没有括号的arity-0方法:

def paramList: List[IWantThis] = ???

如果是这样,则该成员是方法类型,并且您必须在从中提取参数之前获取方法的返回类型:

val meWantArg = classSymbol.member("paramList": TermName).asMethod.returnType
val TypeRef(_,_,args) = meWantArg
于 2013-08-20T13:58:11.540 回答