Skip to content

Is there any way to use untyped AST? #12539

Answered by giiita
scf37 asked this question in Metaprogramming
Discussion options

You must be logged in to vote

This question is probably related to this one.

#12500

However, it is possible to refer to any expression in call site, as in the example below.
It seems that it is no longer possible to refer to it visually from within Quasiquotes as before.

object Main extends App {
  val member: String = "I am Main member"
  println(Macro.getMember())
}
import scala.quoted._
object Macro {
  def getMember()(using q: Quotes): Expr[String] = {
    Select.unique(This(q.reflect.Symbol.spliceOwner.owner), "member").asExprOf[String]
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nicolasstucki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants