I want get StaticAnnotation's parameters defined as:
class Log(logTag: List[LogTag] = Info() :: Nil )
(implicit logger: String => Unit = a => {println(a)})
extends scala.annotation.StaticAnnotation {
inline def apply(defn: Any): Any = meta {
val logTag = ??? //todo
val logger = ??? //todo
}
}
How to get the logTag
and logger
Function values in meta
block?
I have seem meta tutorials about this point. But the Lit
just refers Int
/Double
,etc, rather then custom class type.
You can deconstruct this
as a scala.meta.Tree
to get the class parameters. See http://scalameta.org/tutorial/#HowdoIpassanargumenttothemacroannotation%3F for an example