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
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ abstract class TreeMapWithStages(@constructorOnly ictx: Context) extends TreeMap
val last = enteredSyms
// mark all bindings
new TreeTraverser {
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
markDef(tree)
traverseChildren(tree)
def traverse(tree: Tree)(implicit ctx: Context): Unit = tree match {
case Quoted(t) => traverse(t)(quoteContext)
case Splice(t) => traverse(t)(spliceContext)
case _ =>
markDef(tree)
traverseChildren(tree)
}
}.traverse(pat)
mapOverTree(last)
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/quotedPatterns-1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {
def test(x: quoted.Expr[Int]) given tasty.Reflection = x match {
case '{ val a = '{ println($y) }; 0 } => ??? // error: Not found: y
case _ =>
}
}
6 changes: 6 additions & 0 deletions tests/neg/quotedPatterns-2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {
def test(x: quoted.Expr[Int]) given tasty.Reflection = x match {
case '{ val a = 4; '{ a }; $y } => y // error: access to value a from wrong staging level
case _ =>
}
}
12 changes: 0 additions & 12 deletions tests/neg/quotedPatterns.scala

This file was deleted.

1 change: 1 addition & 0 deletions tests/pos/quotedPatterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object Test {
case '{1 + 2} => '{0}
case '{f($y)} => y
case '{g($y, $z)} => '{$y * $z}
case '{ ((a: Int) => 3)($y) } => y
case '{ 1 + ($y: Int)} => y
// currently gives an unreachable case warning
// but only when used in conjunction with the others.
Expand Down