macwire
macwire copied to clipboard
Wire from parent scope
Depends on lampepfl/dotty#13105
@mbore
import scala.quoted.*
object Macros {
inline def f(): String = ${ fImpl }
def fImpl(using q: Quotes): Expr[String] = {
import q.reflect.*
val classSymbol = Symbol.spliceOwner.owner.owner
classSymbol.memberMethods.find(_.name == "s") match {
case None => '{""}
case Some(s) =>
val t = Select(This(classSymbol), s).appliedToArgss(Nil)
t.asExprOf[String]
}
}
}
This
could be used here to access this
ref.
Ref
can only ref to a term, s
is not a term here.
Seems already resolved.