Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rssh authored and olsdavis committed Apr 4, 2022
1 parent 7e12ed5 commit 7262f10
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
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(_) =>
???

}

0 comments on commit 7262f10

Please sign in to comment.