@@ -98,8 +98,7 @@ import scala.internal.tasty.CompilerInterface.quoteContextWithCompilerInterface
9898 */
9999object Matcher {
100100
101- class QuoteMatcher [QCtx <: QuoteContext & Singleton ](val qctx0 : QCtx ) {
102- val qctx = qctx0.asInstanceOf [qctx0.type { val tasty : qctx0.tasty.type & scala.internal.tasty.CompilerInterface }]
101+ abstract class QuoteMatcher [QCtx <: QuoteContext { val tasty : scala.internal.tasty.CompilerInterface } & Singleton ](val qctx : QCtx ) {
103102
104103 // TODO improve performance
105104
@@ -109,6 +108,9 @@ object Matcher {
109108 import qctx .tasty ._
110109 import Matching ._
111110
111+ def patternHoleSymbol : Symbol
112+ def higherOrderHoleSymbol : Symbol
113+
112114 /** A map relating equivalent symbols from the scrutinee and the pattern
113115 * For example in
114116 * ```
@@ -179,22 +181,22 @@ object Matcher {
179181 /* Term hole */
180182 // Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
181183 case (scrutinee @ Typed (s, tpt1), Typed (TypeApply (patternHole, tpt :: Nil ), tpt2))
182- if patternHole.symbol == qctx.tasty. Definitions_InternalQuotedPatterns_patternHole &&
184+ if patternHole.symbol == patternHoleSymbol &&
183185 s.tpe <:< tpt.tpe &&
184186 tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
185187 matched(scrutinee.seal)
186188
187189 /* Term hole */
188190 // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
189191 case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
190- if patternHole.symbol == qctx.tasty. Definitions_InternalQuotedPatterns_patternHole &&
192+ if patternHole.symbol == patternHoleSymbol &&
191193 scrutinee.tpe <:< tpt.tpe =>
192194 matched(scrutinee.seal)
193195
194196 /* Higher order term hole */
195197 // Matches an open term and wraps it into a lambda that provides the free variables
196198 case (scrutinee, pattern @ Apply (TypeApply (Ident (" higherOrderHole" ), List (Inferred ())), Repeated (args, _) :: Nil ))
197- if pattern.symbol == qctx.tasty. Definitions_InternalQuotedPatterns_higherOrderHole =>
199+ if pattern.symbol == higherOrderHoleSymbol =>
198200
199201 def bodyFn (lambdaArgs : List [Tree ]): Tree = {
200202 val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf [List [Term ]]).toMap
0 commit comments