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.

Daniel Macias
  • 242
  • 3
  • 10
  • possible duplicate of [Finding type parameters via reflection in Scala 2.10?](http://stackoverflow.com/questions/12842729/finding-type-parameters-via-reflection-in-scala-2-10) – ghik Aug 19 '13 at 22:42
  • possible duplicate of [How do I get type parameter from type with type parameter, inside scala macro?](http://stackoverflow.com/questions/17166911/how-do-i-get-type-parameter-from-type-with-type-parameter-inside-scala-macro) – Travis Brown Aug 19 '13 at 22:46

1 Answers1

3

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
gourlaysama
  • 10,828
  • 3
  • 41
  • 50