I'm writing a macro which generate some code like this:
q"_root_.ru.lmars.macropack.TagsAndTags2.$tagName(..$tagParams)"
but I want to generate this code only if $tagName
is defined and have some "marker" (like annotation or some special return type). How to get a Symbol
of $tagName
for this?
It's easy if $tagName
is defined inside TagsAndTags2
object:
object TagsAndTags2
{
def dialog(caption: String): String = ???
}
you can write something like this to get Symbol
of dialog
:
val tagParentAccess = q"_root_.ru.lmars.macropack.TagsAndTags2"
val tagParent = c.typecheck(tagParentAccess, silent = true)
val tagSymbol = tagParent.tpe.member(tagName)
But how to do the same if $tagName
is available via an implicit conversion?
implicit final class UserTags(x: TagsAndTags2.type)
{
def dialog(caption: String): String = ???
}