I have success when the annotation's argument is a literal, like:
@Annotation(2)
class AnnotatedClass
since I can get the value in the macro's impl
with:
c.prefix.tree match {
case Apply(_, List(Literal(Constant(x)))) => x.toInt
}
But I'm stumped when the annotation's argument is not a literal, like:
object Obj {val n = 2}
@Annotation(Obj.n)
class AnnotatedClass
Similar to the false-start in this question, I can match c.prefix.tree
again and pull out the names Obj
and n
, but how do I get the value of Obj.n
?