Skip to content

Commit 08a391d

Browse files
committed
Reposition tasty reflect nodes with no position
1 parent 028d8a2 commit 08a391d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/src/dotty/tools/dotc/transform/Splicer.scala

+11-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,19 @@ object Splicer {
4040
case _ =>
4141
val interpreter = new Interpreter(pos, classLoader)
4242
try {
43+
// TODO try to apply position directly in the TASTy reflect constructors
44+
val positioner = new TreeMap() {
45+
override def transform(tree: tpd.Tree)(implicit ctx: Context): tpd.Tree = {
46+
val tree1 =
47+
if (tree.span.exists) tree
48+
else tree.withSpan(pos.span) // TODO change the source if needed: tree.withPos(pos)
49+
super.transform(tree1)
50+
}
51+
}
4352
// Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree
4453
val interpretedExpr = interpreter.interpret[scala.quoted.Expr[Any]](tree)
45-
interpretedExpr.fold(tree)(x => PickledQuotes.quotedExprToTree(x))
54+
val interpretedTree = interpretedExpr.fold(tree)(x => positioner.transform(PickledQuotes.quotedExprToTree(x)))
55+
interpretedTree
4656
}
4757
catch {
4858
case ex: scala.quoted.QuoteError =>

0 commit comments

Comments
 (0)