Skip to content

Commit 02b3896

Browse files
committed
Port freePatternVars
1 parent a523bca commit 02b3896

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/src/scala/quoted/runtime/impl/Matcher.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import scala.annotation.{Annotation, compileTimeOnly}
66

77
import dotty.tools.dotc
88
import dotty.tools.dotc.core.Contexts._
9-
import dotty.tools.dotc.core.Contexts._
109
import dotty.tools.dotc.core.StdNames.nme
1110

1211
/** Matches a quoted tree against a quoted pattern tree.
@@ -378,17 +377,19 @@ object Matcher {
378377
private object ClosedPatternTerm {
379378
/** Matches a term that does not contain free variables defined in the pattern (i.e. not defined in `Env`) */
380379
def unapply(term: Term)(using Env): Option[term.type] =
381-
if freePatternVars(term).isEmpty then Some(term) else None
380+
if freePatternVars(term.asInstanceOf).isEmpty then Some(term) else None
382381

383382
/** Return all free variables of the term defined in the pattern (i.e. defined in `Env`) */
384-
def freePatternVars(term: Term)(using env: Env): Set[Symbol] =
383+
def freePatternVars(term: dotc.ast.tpd.Tree)(using env: Env): Set[dotc.core.Symbols.Symbol] =
384+
import dotc.ast.tpd.* // TODO remove
385+
import dotc.core.Symbols.* // TODO remove
385386
val accumulator = new TreeAccumulator[Set[Symbol]] {
386-
def foldTree(x: Set[Symbol], tree: Tree)(owner: Symbol): Set[Symbol] =
387+
def apply(x: Set[Symbol], tree: Tree)(using Context): Set[Symbol] =
387388
tree match
388-
case tree: Ident if env.contains(tree.symbol) => foldOverTree(x + tree.symbol, tree)(owner)
389-
case _ => foldOverTree(x, tree)(owner)
389+
case tree: Ident if env.contains(tree.symbol.asInstanceOf) => foldOver(x + tree.symbol, tree)
390+
case _ => foldOver(x, tree)
390391
}
391-
accumulator.foldTree(Set.empty, term)(Symbol.spliceOwner)
392+
accumulator.apply(Set.empty, term)
392393
}
393394

394395
private def treeOptMatches(scrutinee: Option[Tree], pattern: Option[Tree])(using Env): Matching = {

0 commit comments

Comments
 (0)