Skip to content

Commit 869af6d

Browse files
committed
fix #14393
1 parent 1776d81 commit 869af6d

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

library/src/scala/quoted/Quotes.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4391,6 +4391,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
43914391
foldTree(x, tpt)(owner)
43924392
case Typed(expr, tpt) =>
43934393
foldTree(foldTree(x, expr)(owner), tpt)(owner)
4394+
case TypedOrTest(expr, tpt) =>
4395+
foldTree(foldTree(x, expr)(owner), tpt)(owner)
43944396
case NamedArg(_, arg) =>
43954397
foldTree(x, arg)(owner)
43964398
case Assign(lhs, rhs) =>

tests/pos-macros/i14393/Macro_1.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package i14393
2+
import scala.quoted.*
3+
4+
object M {
5+
6+
inline def useFoldTree[X](inline x:X):X = ${
7+
useFoldTreeImpl('x)
8+
}
9+
10+
def useFoldTreeImpl[X:Type](x:Expr[X])(using Quotes):Expr[X] = {
11+
import quotes.reflect.*
12+
val search = new TreeAccumulator[Int] {
13+
def foldTree(s:Int, tree: Tree)(owner: Symbol): Int =
14+
foldOverTree(s,tree)(owner)
15+
}
16+
search.foldTree(0,x.asTerm)(Symbol.spliceOwner)
17+
x
18+
}
19+
20+
}

tests/pos-macros/i14393/Test_2.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package i14393
2+
3+
def thing() =
4+
M.useFoldTree {
5+
6+
Option("") match
7+
case None =>
8+
case Some(_) =>
9+
???
10+
11+
}

0 commit comments

Comments
 (0)