Skip to content

Commit 581569f

Browse files
committed
Fix ${ 'x } -> x and '{ $x } -> x transformation
1 parent 163cc1b commit 581569f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,24 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap
7676
enteredSyms = enteredSyms.tail
7777
}
7878

79+
def dropEmptyBlocks(tree: Tree): Tree = tree match {
80+
case Block(Nil, expr) => dropEmptyBlocks(expr)
81+
case _ => tree
82+
}
83+
7984
tree match {
80-
case Quoted(Spliced(t)) =>
81-
transform(t) // '(~x) --> x
8285

8386
case Quoted(quotedTree) =>
84-
transformQuotation(quotedTree, tree)
85-
86-
case Spliced(Quoted(quotedTree)) =>
87-
transform(quotedTree) // ~('x) --> x
87+
dropEmptyBlocks(quotedTree) match {
88+
case Spliced(t) => transform(t) // '{ $x } --> x
89+
case _ => transformQuotation(quotedTree, tree)
90+
}
8891

89-
case tree @ Spliced(_) =>
90-
transformSplice(tree)
92+
case tree @ Spliced(splicedTree) =>
93+
dropEmptyBlocks(splicedTree) match {
94+
case Quoted(t) => transform(t) // ${ 'x } --> x
95+
case _ => transformSplice(tree)
96+
}
9197

9298
case Block(stats, _) =>
9399
val last = enteredSyms

0 commit comments

Comments
 (0)