Is there anyway to go from a Symbol or Type to a Tree when defining a Scala macro?
Specifically the scenario is wanting to look up a literal on a companion object.
In scala code this looks something like this:
class Fred(a: String)
object Fred {
val FredDescription = "hello"
}
In the macro I have access to a WeakTypeTag of Fred and can use that to get access to the companion and its type signature:
context.universe.weakTypeOf[A].typeSymbol.companionSymbol.typeSignature
But I can't see any way of accessing the literals or tree to match out the literals for the companion object.
Is this possible? Is there a trick to getting a Tree for some arbitrary Type or Symbol?