@@ -103,14 +103,13 @@ import dotty.tools.dotc.core.StdNames.nme
103103object Matcher {
104104 import tpd .*
105105
106- class QuoteMatcher [ QCtx <: Quotes & Singleton ] (val qctx : QCtx )(using Context ) {
106+ class QuoteMatcher (val quotes : Quotes )(using Context ) {
107107
108108 // TODO improve performance
109109
110- // TODO use flag from qctx.reflect . Maybe -debug or add -debug-macros
110+ // TODO use flag from Context . Maybe -debug or add -debug-macros
111111 private inline val debug = false
112112
113- import qctx .reflect ._
114113 import Matching ._
115114
116115 /** A map relating equivalent symbols from the scrutinee and the pattern
@@ -124,11 +123,11 @@ object Matcher {
124123
125124 inline private def withEnv [T ](env : Env )(inline body : Env ?=> T ): T = body(using env)
126125
127- def termMatch (scrutineeTerm : Term , patternTerm : Term ): Option [Tuple ] =
126+ def termMatch (scrutineeTerm : tpd. Tree , patternTerm : tpd. Tree ): Option [Tuple ] =
128127 given Env = Map .empty
129128 scrutineeTerm =?= patternTerm
130129
131- def typeTreeMatch (scrutineeTypeTree : TypeTree , patternTypeTree : TypeTree ): Option [Tuple ] =
130+ def typeTreeMatch (scrutineeTypeTree : tpd. Tree , patternTypeTree : tpd. Tree ): Option [Tuple ] =
132131 given Env = Map .empty
133132 scrutineeTypeTree =?= patternTypeTree
134133
@@ -139,9 +138,6 @@ object Matcher {
139138 case _ => notMatched
140139 }
141140
142- extension (scrutinee : Tree )
143- private def =?= (pattern : Tree )(using Env ): Matching =
144- scrutinee.asInstanceOf [tpd.Tree ] =?= pattern.asInstanceOf [tpd.Tree ]
145141 extension (scrutinees : List [tpd.Tree ])
146142 private def =?= (patterns : List [tpd.Tree ])(using Env )(using DummyImplicit ): Matching =
147143 matchLists(scrutinees, patterns)(_ =?= _)
@@ -206,14 +202,14 @@ object Matcher {
206202 if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
207203 s.tpe <:< tpt.tpe &&
208204 tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
209- matched(qctx .reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [qctx .reflect.Tree ]))
205+ matched(quotes .reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [quotes .reflect.Tree ]))
210206
211207 /* Term hole */
212208 // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
213209 case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
214210 if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
215211 scrutinee.tpe <:< tpt.tpe =>
216- matched(qctx .reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [qctx .reflect.Tree ]))
212+ matched(quotes .reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [quotes .reflect.Tree ]))
217213
218214 /* Higher order term hole */
219215 // Matches an open term and wraps it into a lambda that provides the free variables
@@ -241,7 +237,7 @@ object Matcher {
241237 MethodType (names)(
242238 _ => argTypes, _ => resType),
243239 (meth, x) => tpd.TreeOps (bodyFn(x)).changeNonLocalOwners(meth.asInstanceOf ))
244- matched(qctx .reflect.TreeMethods .asExpr(res.asInstanceOf [qctx .reflect.Tree ]))
240+ matched(quotes .reflect.TreeMethods .asExpr(res.asInstanceOf [quotes .reflect.Tree ]))
245241
246242 //
247243 // Match two equivalent trees
@@ -369,8 +365,8 @@ object Matcher {
369365 |
370366 |with environment: ${summon[Env ]}
371367 |
372- |Scrutinee: ${Printer .TreeStructure .show(scrutinee.asInstanceOf )}
373- |Pattern: ${Printer .TreeStructure .show(pattern.asInstanceOf )}
368+ |Scrutinee: ${quotes.reflect. Printer .TreeStructure .show(scrutinee.asInstanceOf )}
369+ |Pattern: ${quotes.reflect. Printer .TreeStructure .show(pattern.asInstanceOf )}
374370 |
375371 | """ .stripMargin)
376372 notMatched
0 commit comments