I'll get straight to the business.
Let's say that I have the following trait definition:
trait Routable{
def routing(): String
}
And I'm defining the following class:
case class MyEvent(name: String, age: Int) extends Routable{
override def routing(): String = "this is my routing key"
}
I'm trying to make a macro called routeOf[MyEvent]
to return the routing key of the defined class.
I tried so many things for the last 3 days and I'm starting to wonder if it is possible at all...
My macro definition is:
def routeOf[T]: Any = macro RouteOfMacro.impl[T]
def impl[T: c.WeakTypeTag](c: whitebox.Context): c.Tree
But I can't find how to extract the method from the WeakTypeTag (and the internet is not full with examples).
So can it be done?