@@ -481,14 +481,16 @@ object QuoteMatcher {
481
481
/*
482
482
* PR-17567 Remaining TODOs
483
483
* * [ ] Implicit / Contextual parameters
484
- * * [ ] Nested Method Types
484
+ * * [x ] Nested Method Types
485
485
* * [ ] Erased Types
486
486
*/
487
487
def adaptTypes (tpe : Type )(using Context ): Type =
488
488
new Types .TypeMap {
489
489
def apply (tp : Types .Type ): Types .Type = tp match
490
490
case tp : MethodType => {
491
- return defn.FunctionOf (tp.paramInfos, tp.resultType)
491
+ val paramInfos = tp.paramInfos map adaptTypes
492
+ val resultType = adaptTypes(tp.resultType)
493
+ return defn.FunctionOf (paramInfos, resultType)
492
494
}
493
495
case _ => mapOver(tp)
494
496
}.apply(tpe)
@@ -523,16 +525,28 @@ object QuoteMatcher {
523
525
* because the type of `g` is `Int => Int` due to eta expansion.
524
526
*
525
527
* Remaining TODOs from issue-17105
526
- * * [ ] cover the case of nested method call
528
+ * * [x ] cover the case of nested method call
527
529
* * [ ] contextual params?
528
530
* * [ ] erasure types?
531
+ * * [ ] eta-expand only HOAS param methods
529
532
*/
530
533
case Apply (methId : Ident , args) =>
531
534
val fnId = env.get(tree.symbol).flatMap(argsMap.get).getOrElse(tree)
532
535
ctx.typer.typed(
533
536
untpd.Apply (
534
537
untpd.Select (untpd.TypedSplice (fnId), nme.apply),
535
538
args.map(untpd.TypedSplice (_))))
539
+ case Apply (fun, args) =>
540
+ val tfun = transform(fun)
541
+ val targs = transform(args)
542
+ tfun.tpe match
543
+ // TODO issue-17105: Is this pattern appropriate for methods?
544
+ case tp : MethodOrPoly => cpy.Apply (tree)(tfun, targs)
545
+ // TODO issue-17105: Appropriate pattern for function (appliable?) types?
546
+ case _ => ctx.typer.typed(
547
+ untpd.Apply (
548
+ untpd.Select (untpd.TypedSplice (tfun), nme.apply),
549
+ args map (untpd.TypedSplice (_))))
536
550
case tree : Ident => env.get(tree.symbol).flatMap(argsMap.get).getOrElse(tree)
537
551
case tree => super .transform(tree)
538
552
}.transform(tree)
0 commit comments