Skip to content

Commit a923e6a

Browse files
Merge pull request #7503 from dotty-staging/fix-treemap
Fix TreeMap's transformTerm wrt UnApply
2 parents f61c631 + f97461f commit a923e6a

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
110110

111111
def matchStatement(tree: Tree)(given Context): Option[Statement] = tree match {
112112
case _: PatternTree => None
113-
case tree if tree.isTerm => Some(tree)
113+
case tree if tree.isTerm => matchTerm(tree)
114114
case _ => matchDefinition(tree)
115115
}
116116

@@ -226,6 +226,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
226226
type Term = tpd.Tree
227227

228228
def matchTerm(tree: Tree)(given Context): Option[Term] = tree match {
229+
case _ if matchTree_Unapply(tree).isDefined => None
229230
case _: PatternTree => None
230231
case x: tpd.SeqLiteral => Some(tree)
231232
case _ if tree.isTerm => Some(tree)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted.{ given, _ }
2+
3+
inline def mcr(x: => Unit): Unit = ${mcrImpl('x)}
4+
def mcrImpl(x: Expr[Unit])(given ctx: QuoteContext): Expr[Unit] =
5+
import ctx.tasty.{ given, _ }
6+
val tr: Term = x.unseal
7+
object m extends TreeMap
8+
m.transformTerm(tr).seal.cast[Unit]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@main def Test = mcr {
2+
val (a, b) = ???
3+
println(s"Foo bar")
4+
}

0 commit comments

Comments
 (0)