File tree 3 files changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/tastyreflect
tests/pos-macros/treemap-unapply
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
110
110
111
111
def matchStatement (tree : Tree )(given Context ): Option [Statement ] = tree match {
112
112
case _ : PatternTree => None
113
- case tree if tree.isTerm => Some (tree)
113
+ case tree if tree.isTerm => matchTerm (tree)
114
114
case _ => matchDefinition(tree)
115
115
}
116
116
@@ -226,6 +226,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
226
226
type Term = tpd.Tree
227
227
228
228
def matchTerm (tree : Tree )(given Context ): Option [Term ] = tree match {
229
+ case _ if matchTree_Unapply(tree).isDefined => None
229
230
case _ : PatternTree => None
230
231
case x : tpd.SeqLiteral => Some (tree)
231
232
case _ if tree.isTerm => Some (tree)
Original file line number Diff line number Diff line change
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 ]
Original file line number Diff line number Diff line change
1
+ @ main def Test = mcr {
2
+ val (a, b) = ???
3
+ println(s " Foo bar " )
4
+ }
You can’t perform that action at this time.
0 commit comments