mercredi 23 septembre 2015

In Scala how can I reflect on a typedef (eg. type Data = Map[String,Any])?

I'm writing some reflection code. I have a class like this:

case class Foo(
   info : Map[String,Any]
)

I reflect on this class like this:

ctor.typeSignature.paramLists.head.map( f => {
   println("F: "+f.typeSignature)
})

When defined as above I see what I expect for the type of member info: Map[String,scala.Any]

But... if I do this:

type Data = Map[String,Any]
case class Foo(
   info : Data
)

Now I see the type of info as: co.blocke.scalajack.test.v4.Data

How can I tell if a type like Data above is actually a typedef any how can I see what it resolves to? (the type of 'f' in the clip above is universe.Symbol)

I mistakenly thought it was compiler-candy and after compilation it would have resolved to its defined type, but apparently not!





Aucun commentaire:

Enregistrer un commentaire