@@ -40,13 +40,15 @@ object Splicer {
4040 def splice (tree : Tree , pos : SourcePosition , classLoader : ClassLoader )(using Context ): Tree = tree match {
4141 case Quoted (quotedTree) => quotedTree
4242 case _ =>
43- val interpreter = new Interpreter (pos, classLoader)
4443 val macroOwner = ctx.newSymbol(ctx.owner, nme.MACROkw , Macro | Synthetic , defn.AnyType , coord = tree.span)
4544 try
4645 inContext(ctx.withOwner(macroOwner)) {
46+ val interpreter = new Interpreter (pos, classLoader)
47+
4748 // Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree
4849 val interpretedExpr = interpreter.interpret[scala.quoted.QuoteContext => scala.quoted.Expr [Any ]](tree)
4950 val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes .quotedExprToTree(macroClosure(QuoteContext ())))
51+
5052 checkEscapedVariables(interpretedTree, macroOwner)
5153 }.changeOwner(macroOwner, ctx.owner)
5254 catch {
@@ -295,10 +297,10 @@ object Splicer {
295297 }
296298
297299 private def interpretQuote (tree : Tree )(implicit env : Env ): Object =
298- new scala.internal.quoted.Expr (Inlined (EmptyTree , Nil , tree).withSpan(tree.span), QuoteContext .scopeId)
300+ new scala.internal.quoted.Expr (Inlined (EmptyTree , Nil , PickledQuotes .healOwner( tree) ).withSpan(tree.span), QuoteContext .scopeId)
299301
300302 private def interpretTypeQuote (tree : Tree )(implicit env : Env ): Object =
301- new scala.internal.quoted.Type (tree, QuoteContext .scopeId)
303+ new scala.internal.quoted.Type (PickledQuotes .healOwner( tree) , QuoteContext .scopeId)
302304
303305 private def interpretLiteral (value : Any )(implicit env : Env ): Object =
304306 value.asInstanceOf [Object ]
0 commit comments