@@ -253,7 +253,7 @@ object QuoteMatcher {
253
253
val captureEnv = env.filter((k, v) => ! capturedSymbols.contains(v))
254
254
withEnv(captureEnv) {
255
255
scrutinee match
256
- case ClosedPatternTerm (scrutinee) => matchedOpen(scrutinee, pattern.tpe, capturedIds, env)
256
+ case ClosedPatternTerm (scrutinee) => matchedOpen(scrutinee, pattern.tpe, capturedIds, args.map(_.tpe), env)
257
257
case _ => notMatched
258
258
}
259
259
@@ -473,35 +473,15 @@ object QuoteMatcher {
473
473
*
474
474
* @param tree Scrutinee sub-tree that matched
475
475
* @param patternTpe Type of the pattern hole (from the pattern)
476
- * @param args HOAS arguments (from the pattern)
476
+ * @param argIds Identifiers of HOAS arguments (from the pattern)
477
+ * @param argTypes Eta-expanded types of HOAS arguments (from the pattern)
477
478
* @param env Mapping between scrutinee and pattern variables
478
479
*/
479
- case OpenTree (tree : Tree , patternTpe : Type , args : List [Tree ], env : Env )
480
+ case OpenTree (tree : Tree , patternTpe : Type , argIds : List [Tree ], argTypes : List [ Type ], env : Env )
480
481
481
482
/** The Definitions object */
482
483
def defn (using Context ): Definitions = ctx.definitions
483
484
484
- /*
485
- * PR-17567 Remaining TODOs
486
- * * [x] Implicit / Contextual parameters
487
- * * [x] Nested Method Types
488
- * * [x] Refinment Types
489
- * * [ ] Erased Types
490
- */
491
- def adaptTypes (tpe : Type )(using Context ): Type =
492
- tpe match {
493
- case tpe : MethodType if tpe.isResultDependent =>
494
- RefinedType (
495
- defn.FunctionOf (tpe.paramInfos, adaptTypes(tpe.nonDependentResultApprox), tpe.isImplicitMethod),
496
- nme.apply,
497
- tpe
498
- )
499
-
500
- case tp : MethodType =>
501
- defn.FunctionOf (tp.paramInfos, adaptTypes(tp.resultType), tp.isImplicitMethod)
502
- case tp => tp
503
- }
504
-
505
485
/** Return the expression that was extracted from a hole.
506
486
*
507
487
* If it was a closed expression it returns that expression. Otherwise,
@@ -513,16 +493,17 @@ object QuoteMatcher {
513
493
def toExpr (mapTypeHoles : TypeMap , spliceScope : Scope )(using Context ): Expr [Any ] = this match
514
494
case MatchResult .ClosedTree (tree) =>
515
495
new ExprImpl (tree, spliceScope)
516
- case MatchResult .OpenTree (tree, patternTpe, args, env) =>
517
- val names : List [TermName ] = args.map {
496
+ case MatchResult .OpenTree (tree, patternTpe, argIds, argTypes, env) =>
497
+ val names : List [TermName ] = argIds.map {
498
+ // TODO 17105: Do we need this case?
518
499
case Block (List (DefDef (nme.ANON_FUN , _, _, Apply (Ident (name), _))), _) => name.asTermName
519
500
case arg => arg.symbol.name.asTermName
520
501
}
521
- val paramTypes = args .map(x => adaptTypes( mapTypeHoles(x.tpe.widenTermRefExpr)) )
502
+ val paramTypes = argTypes .map(mapTypeHoles)
522
503
val methTpe = MethodType (names)(_ => paramTypes, _ => mapTypeHoles(patternTpe))
523
504
val meth = newAnonFun(ctx.owner, methTpe)
524
505
def bodyFn (lambdaArgss : List [List [Tree ]]): Tree = {
525
- val argsMap = args .view.map(_.symbol).zip(lambdaArgss.head).toMap
506
+ val argsMap = argIds .view.map(_.symbol).zip(lambdaArgss.head).toMap
526
507
val body = new TreeMap {
527
508
override def transform (tree : Tree )(using Context ): Tree =
528
509
tree match
@@ -560,8 +541,8 @@ object QuoteMatcher {
560
541
private inline def matched (tree : Tree )(using Context ): MatchingExprs =
561
542
Seq (MatchResult .ClosedTree (tree))
562
543
563
- private def matchedOpen (tree : Tree , patternTpe : Type , args : List [Tree ], env : Env )(using Context ): MatchingExprs =
564
- Seq (MatchResult .OpenTree (tree, patternTpe, args , env))
544
+ private def matchedOpen (tree : Tree , patternTpe : Type , argIds : List [Tree ], argTypes : List [ Type ], env : Env )(using Context ): MatchingExprs =
545
+ Seq (MatchResult .OpenTree (tree, patternTpe, argIds, argTypes , env))
565
546
566
547
extension (self : MatchingExprs )
567
548
/** Concatenates the contents of two successful matchings */
0 commit comments