@@ -3,8 +3,11 @@ package transform
33
44import dotty .tools .dotc .ast .tpd
55import dotty .tools .dotc .core .Contexts ._
6+ import dotty .tools .dotc .core .Decorators ._
7+ import dotty .tools .dotc .core .Symbols ._
68import dotty .tools .dotc .core .quoted ._
79import dotty .tools .dotc .interpreter ._
10+ import dotty .tools .dotc .util .SourcePosition
811
912/** Utility class to splice quoted expressions */
1013object Splicer {
@@ -20,9 +23,18 @@ object Splicer {
2023 }
2124
2225 /** Splice the Tree for a Quoted expression which is constructed via a reflective call to the given method */
23- private def reflectiveSplice (tree : Tree )(implicit ctx : Context ): Tree = {
24- val interpreter = new Interpreter
25- interpreter.interpretTree[scala.quoted.Expr [_]](tree).map(PickledQuotes .quotedExprToTree).getOrElse(tree)
26+ private def reflectiveSplice (tree0 : Tree )(implicit ctx : Context ): Tree = {
27+ val interpreter = new Interpreter {
28+ override protected def interpretTreeImpl (tree : Tree , env : Env ): AnyRef = tree match {
29+ case tree : RefTree if tree.symbol eq defn.QuotedReporterDummy => new Reporter (tree0.pos, ctx)
30+ case _ => super .interpretTreeImpl(tree, env)
31+ }
32+ }
33+ interpreter.interpretTree[scala.quoted.Expr [_]](tree0).map(PickledQuotes .quotedExprToTree).getOrElse(tree0)
2634 }
2735
36+ private class Reporter (pos : SourcePosition , ctx : Context ) extends scala.quoted.Reporter {
37+ override def error (message : String ): Unit = ctx.error(message, pos)
38+ override def warn (message : String ): Unit = ctx.warning(message, pos)
39+ }
2840}
0 commit comments