@@ -201,14 +201,14 @@ object Matcher {
201201 if patternHole.symbol.eq(defn.QuotedRuntimePatterns_patternHole ) &&
202202 s.tpe <:< tpt.tpe &&
203203 tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
204- matched(quotes.reflect. TreeMethods .asExpr( scrutinee. asInstanceOf [quotes.reflect. Tree ]) )
204+ matched(scrutinee)
205205
206206 /* Term hole */
207207 // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
208208 case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
209209 if patternHole.symbol.eq(defn.QuotedRuntimePatterns_patternHole ) &&
210210 scrutinee.tpe <:< tpt.tpe =>
211- matched(quotes.reflect. TreeMethods .asExpr( scrutinee. asInstanceOf [quotes.reflect. Tree ]) )
211+ matched(scrutinee)
212212
213213 /* Higher order term hole */
214214 // Matches an open term and wraps it into a lambda that provides the free variables
@@ -235,8 +235,8 @@ object Matcher {
235235 ctx.owner,
236236 MethodType (names)(
237237 _ => argTypes, _ => resType),
238- (meth, x) => TreeOps (bodyFn(x)).changeNonLocalOwners(meth. asInstanceOf ))
239- matched(quotes.reflect. TreeMethods .asExpr( res. asInstanceOf [quotes.reflect. Tree ]) )
238+ (meth, x) => TreeOps (bodyFn(x)).changeNonLocalOwners(meth))
239+ matched(res)
240240
241241 //
242242 // Match two equivalent trees
@@ -421,8 +421,11 @@ object Matcher {
421421 private object Matching {
422422
423423 def notMatched : Matching = None
424+
424425 val matched : Matching = Some (Tuple ())
425- def matched (x : Any ): Matching = Some (Tuple1 (x))
426+
427+ def matched (tree : Tree )(using Context ): Matching =
428+ Some (Tuple1 (new ExprImpl (tree, SpliceScope .getCurrent)))
426429
427430 extension (self : Matching )
428431 def asOptionOfTuple : Option [Tuple ] = self
0 commit comments