Skip to content

Commit

Permalink
Merge pull request #14396 from rssh/fix-14393
Browse files Browse the repository at this point in the history
 fix #14393
  • Loading branch information
nicolasstucki authored Feb 3, 2022
2 parents 8bb2453 + 869af6d commit 3d3f820
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 3d3f820

Please sign in to comment.