@@ -2169,7 +2169,7 @@ trait Applications extends Compatibility {
21692169 val alts0 = alts.filterConserve(_.widen.stripPoly.isImplicitMethod)
21702170 if alts0 ne alts then return resolve(alts0)
21712171 else if alts.exists(_.widen.stripPoly.isContextualMethod) then
2172- return resolveMapped(alts, alt => stripImplicit(alt.widen), pt, srcPos)
2172+ return resolveMapped(alt => stripImplicit(alt.widen))(alts , pt, srcPos)
21732173 case _ =>
21742174
21752175 var found = withoutMode(Mode .ImplicitsEnabled )(resolveOverloaded1(alts, pt, srcPos))
@@ -2405,7 +2405,7 @@ trait Applications extends Compatibility {
24052405 TypeOps .boundsViolations(targs1, tp.paramInfos, _.substParams(tp, _), NoType ).isEmpty
24062406 val alts2 = alts1.filter(withinBounds)
24072407 if isDetermined(alts2) then alts2
2408- else resolveMapped(alts1, _.widen.appliedTo(targs1.tpes), pt1, srcPos)
2408+ else resolveMapped(_.widen.appliedTo(targs1.tpes))(alts1 , pt1, srcPos)
24092409
24102410 case pt =>
24112411 val compat = alts.filterConserve(normalizedCompatible(_, pt, keepConstraint = false ))
@@ -2470,11 +2470,11 @@ trait Applications extends Compatibility {
24702470 case pt @ FunProto (_, PolyProto (targs, resType)) =>
24712471 // try to narrow further with snd argument list and following type params
24722472 warnOnPriorityChange(candidates, found):
2473- resolveMapped(_, skipParamClause(pt.typedArgs().tpes, targs.tpes), resType, srcPos)
2473+ resolveMapped(skipParamClause(pt.typedArgs().tpes, targs.tpes))(_ , resType, srcPos)
24742474 case pt @ FunProto (_, resType : FunOrPolyProto ) =>
24752475 // try to narrow further with snd argument list
24762476 warnOnPriorityChange(candidates, found):
2477- resolveMapped(_, skipParamClause(pt.typedArgs().tpes, Nil ), resType, srcPos)
2477+ resolveMapped(skipParamClause(pt.typedArgs().tpes, Nil ))(_ , resType, srcPos)
24782478 case _ =>
24792479 // prefer alternatives that need no eta expansion
24802480 val noCurried = alts.filterConserve(! resultIsMethod(_))
@@ -2523,11 +2523,13 @@ trait Applications extends Compatibility {
25232523 recur(paramss, 0 )
25242524 case _ => (Nil , 0 )
25252525
2526- /** Resolve overloading by mapping to a different problem where each alternative's
2527- * type is mapped with `f`, alternatives with non-existing types or symbols are dropped, and the
2528- * expected type is `pt`. Map the results back to the original alternatives.
2526+ /** Resolve with `g` by mapping to a different problem where each alternative's type
2527+ * is mapped with `f`, alternatives with non-existing types or symbols are dropped,
2528+ * and the expected type is `pt`. Map the results back to the original alternatives.
25292529 */
2530- def resolveMapped (alts : List [TermRef ], f : TermRef => Type , pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
2530+ def resolveMapped
2531+ (f : TermRef => Type , g : (List [TermRef ], Type , SrcPos ) => Context ?=> List [TermRef ] = resolveOverloaded)
2532+ (alts : List [TermRef ], pt : Type , srcPos : SrcPos )(using Context ): List [TermRef ] =
25312533 val reverseMapping = alts.flatMap { alt =>
25322534 val t = f(alt)
25332535 if t.exists && alt.symbol.exists then
@@ -2550,8 +2552,9 @@ trait Applications extends Compatibility {
25502552 }
25512553 val mapped = reverseMapping.map(_._1)
25522554 overload.println(i " resolve mapped: ${mapped.map(_.widen)}%, % with $pt" )
2553- resolveOverloaded (mapped, pt, srcPos)(using ctx.retractMode(Mode .SynthesizeExtMethodReceiver ))
2555+ g (mapped, pt, srcPos)(using ctx.retractMode(Mode .SynthesizeExtMethodReceiver ))
25542556 .map(reverseMapping.toMap)
2557+ end resolveMapped
25552558
25562559 /** Try to typecheck any arguments in `pt` that are function values missing a
25572560 * parameter type. If the formal parameter types corresponding to a closure argument
0 commit comments