@@ -177,28 +177,8 @@ object Matcher {
177177 val scrutinee = normalize(scrutinee0)
178178 val pattern = normalize(pattern0)
179179
180- (scrutinee, pattern) match {
181-
182- /* Term hole */
183- // Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
184- case (scrutinee @ Typed (s, tpt1), Typed (TypeApply (patternHole, tpt :: Nil ), tpt2))
185- if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
186- s.tpe <:< tpt.tpe &&
187- tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
188- matched(scrutinee.asExpr)
189-
190- /* Term hole */
191- // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
192- case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
193- if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
194- scrutinee.tpe <:< tpt.tpe =>
195- matched(scrutinee.asExpr)
196-
197-
198- // No Match
199- case _ =>
200- otherCases(scrutinee.asInstanceOf , pattern.asInstanceOf )
201- }
180+ otherCases(scrutinee.asInstanceOf , pattern.asInstanceOf )
181+
202182 }
203183 end extension
204184
@@ -231,6 +211,21 @@ object Matcher {
231211
232212 (scrutinee, pattern) match
233213
214+ /* Term hole */
215+ // Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
216+ case (scrutinee @ Typed (s, tpt1), Typed (TypeApply (patternHole, tpt :: Nil ), tpt2))
217+ if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
218+ s.tpe <:< tpt.tpe &&
219+ tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
220+ matched(qctx.reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [qctx.reflect.Tree ]))
221+
222+ /* Term hole */
223+ // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
224+ case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
225+ if patternHole.symbol.eq(dotc.core.Symbols .defn.QuotedRuntimePatterns_patternHole ) &&
226+ scrutinee.tpe <:< tpt.tpe =>
227+ matched(qctx.reflect.TreeMethods .asExpr(scrutinee.asInstanceOf [qctx.reflect.Tree ]))
228+
234229 /* Higher order term hole */
235230 // Matches an open term and wraps it into a lambda that provides the free variables
236231 case (scrutinee, pattern @ Apply (TypeApply (Ident (_), List (TypeTree ())), SeqLiteral (args, _) :: Nil ))
@@ -428,8 +423,8 @@ object Matcher {
428423
429424 private object ClosedPatternTerm {
430425 /** Matches a term that does not contain free variables defined in the pattern (i.e. not defined in `Env`) */
431- def unapply (term : Term )(using Env ): Option [term.type ] =
432- if freePatternVars(term. asInstanceOf ).isEmpty then Some (term) else None
426+ def unapply (term : tpd. Tree )(using Env ): Option [term.type ] =
427+ if freePatternVars(term).isEmpty then Some (term) else None
433428
434429 /** Return all free variables of the term defined in the pattern (i.e. defined in `Env`) */
435430 def freePatternVars (term : dotc.ast.tpd.Tree )(using env : Env ): Set [dotc.core.Symbols .Symbol ] =
0 commit comments