Getting Parameters from Scala Macro Annotation explains how to get parameters from a macro annotation. However, if I have several parameters with default values:
class Foo(b: Boolean = false, i: Int = 0) extends StaticAnnotation { ... }
I need to write (based on the answer to that question)
val (b, i) = c.prefix.tree match {
case q"new Foo(..$args)" => ???
}
The logic in ???
seems to become very nasty: I need to handle both positional and named parameters, no simple access to the default values, etc. Is there a way to simplify it?