Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4391,6 +4391,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
foldTree(x, tpt)(owner)
case Typed(expr, tpt) =>
foldTree(foldTree(x, expr)(owner), tpt)(owner)
case TypedOrTest(expr, tpt) =>
foldTree(foldTree(x, expr)(owner), tpt)(owner)
case NamedArg(_, arg) =>
foldTree(x, arg)(owner)
case Assign(lhs, rhs) =>
Expand Down
20 changes: 20 additions & 0 deletions tests/pos-macros/i14393/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package i14393
import scala.quoted.*

object M {

inline def useFoldTree[X](inline x:X):X = ${
useFoldTreeImpl('x)
}

def useFoldTreeImpl[X:Type](x:Expr[X])(using Quotes):Expr[X] = {
import quotes.reflect.*
val search = new TreeAccumulator[Int] {
def foldTree(s:Int, tree: Tree)(owner: Symbol): Int =
foldOverTree(s,tree)(owner)
}
search.foldTree(0,x.asTerm)(Symbol.spliceOwner)
x
}

}
11 changes: 11 additions & 0 deletions tests/pos-macros/i14393/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package i14393

def thing() =
M.useFoldTree {

Option("") match
case None =>
case Some(_) =>
???

}