@@ -177,28 +177,8 @@ object Matcher {
177
177
val scrutinee = normalize(scrutinee0)
178
178
val pattern = normalize(pattern0)
179
179
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
+
202
182
}
203
183
end extension
204
184
@@ -231,6 +211,21 @@ object Matcher {
231
211
232
212
(scrutinee, pattern) match
233
213
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
+
234
229
/* Higher order term hole */
235
230
// Matches an open term and wraps it into a lambda that provides the free variables
236
231
case (scrutinee, pattern @ Apply (TypeApply (Ident (_), List (TypeTree ())), SeqLiteral (args, _) :: Nil ))
@@ -428,8 +423,8 @@ object Matcher {
428
423
429
424
private object ClosedPatternTerm {
430
425
/** 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
433
428
434
429
/** Return all free variables of the term defined in the pattern (i.e. defined in `Env`) */
435
430
def freePatternVars (term : dotc.ast.tpd.Tree )(using env : Env ): Set [dotc.core.Symbols .Symbol ] =
0 commit comments