@@ -4,6 +4,9 @@ package runtime.impl
4
4
import scala .annotation .internal .sharable
5
5
import scala .annotation .{Annotation , compileTimeOnly }
6
6
7
+ import dotty .tools .dotc
8
+ import dotty .tools .dotc .core .Contexts ._
9
+
7
10
/** Matches a quoted tree against a quoted pattern tree.
8
11
* A quoted pattern tree may have type and term holes in addition to normal terms.
9
12
*
@@ -96,7 +99,7 @@ import scala.annotation.{Annotation, compileTimeOnly}
96
99
*/
97
100
object Matcher {
98
101
99
- abstract class QuoteMatcher [QCtx <: Quotes & Singleton ](val qctx : QCtx ) {
102
+ class QuoteMatcher [QCtx <: Quotes & Singleton ](val qctx : QCtx )( using Context ) {
100
103
101
104
// TODO improve performance
102
105
@@ -106,9 +109,6 @@ object Matcher {
106
109
import qctx .reflect ._
107
110
import Matching ._
108
111
109
- def patternHoleSymbol : Symbol
110
- def higherOrderHoleSymbol : Symbol
111
-
112
112
/** A map relating equivalent symbols from the scrutinee and the pattern
113
113
* For example in
114
114
* ```
@@ -179,22 +179,22 @@ object Matcher {
179
179
/* Term hole */
180
180
// Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
181
181
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 ) &&
183
183
s.tpe <:< tpt.tpe &&
184
184
tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
185
185
matched(scrutinee.asExpr)
186
186
187
187
/* Term hole */
188
188
// Match a scala.internal.Quoted.patternHole and return the scrutinee tree
189
189
case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
190
- if patternHole.symbol == patternHoleSymbol &&
190
+ if patternHole.symbol.eq(dotc.core. Symbols .defn. QuotedRuntimePatterns_patternHole ) &&
191
191
scrutinee.tpe <:< tpt.tpe =>
192
192
matched(scrutinee.asExpr)
193
193
194
194
/* Higher order term hole */
195
195
// Matches an open term and wraps it into a lambda that provides the free variables
196
196
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 ) =>
198
198
199
199
def bodyFn (lambdaArgs : List [Tree ]): Tree = {
200
200
val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf [List [Term ]]).toMap
0 commit comments