@@ -4,6 +4,9 @@ package runtime.impl
44import scala .annotation .internal .sharable
55import scala .annotation .{Annotation , compileTimeOnly }
66
7+ import dotty .tools .dotc
8+ import dotty .tools .dotc .core .Contexts ._
9+
710/** Matches a quoted tree against a quoted pattern tree.
811 * A quoted pattern tree may have type and term holes in addition to normal terms.
912 *
@@ -96,7 +99,7 @@ import scala.annotation.{Annotation, compileTimeOnly}
9699 */
97100object Matcher {
98101
99- abstract class QuoteMatcher [QCtx <: Quotes & Singleton ](val qctx : QCtx ) {
102+ class QuoteMatcher [QCtx <: Quotes & Singleton ](val qctx : QCtx )( using Context ) {
100103
101104 // TODO improve performance
102105
@@ -106,9 +109,6 @@ object Matcher {
106109 import qctx .reflect ._
107110 import Matching ._
108111
109- def patternHoleSymbol : Symbol
110- def higherOrderHoleSymbol : Symbol
111-
112112 /** A map relating equivalent symbols from the scrutinee and the pattern
113113 * For example in
114114 * ```
@@ -179,22 +179,22 @@ object Matcher {
179179 /* Term hole */
180180 // Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
181181 case (scrutinee @ Typed (s, tpt1), Typed (TypeApply (patternHole, tpt :: Nil ), tpt2))
182- if patternHole.symbol == patternHoleSymbol &&
182+ if patternHole.symbol.eq(dotc.core. Symbols .defn. QuotedRuntimePatterns_patternHole ) &&
183183 s.tpe <:< tpt.tpe &&
184184 tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
185185 matched(scrutinee.asExpr)
186186
187187 /* Term hole */
188188 // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
189189 case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
190- if patternHole.symbol == patternHoleSymbol &&
190+ if patternHole.symbol.eq(dotc.core. Symbols .defn. QuotedRuntimePatterns_patternHole ) &&
191191 scrutinee.tpe <:< tpt.tpe =>
192192 matched(scrutinee.asExpr)
193193
194194 /* Higher order term hole */
195195 // Matches an open term and wraps it into a lambda that provides the free variables
196196 case (scrutinee, pattern @ Apply (TypeApply (Ident (" higherOrderHole" ), List (Inferred ())), Repeated (args, _) :: Nil ))
197- if pattern.symbol == higherOrderHoleSymbol =>
197+ if pattern.symbol.eq(dotc.core. Symbols .defn. QuotedRuntimePatterns_higherOrderHole ) =>
198198
199199 def bodyFn (lambdaArgs : List [Tree ]): Tree = {
200200 val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf [List [Term ]]).toMap
0 commit comments