@@ -533,19 +533,17 @@ trait Applications extends Compatibility {
533
533
case formal :: formals1 =>
534
534
535
535
/** Add result of typing argument `arg` against parameter type `formal`.
536
- * @return A type transformation to apply to all arguments following this one.
536
+ * @return The remaining formal parameter types. If the method is parameter-dependent
537
+ * this means substituting the actual argument type for the current formal parameter
538
+ * in the remaining formal parameters.
537
539
*/
538
- def addTyped (arg : Arg , formal : Type ): Type => Type = {
540
+ def addTyped (arg : Arg , formal : Type ): List [ Type ] =
539
541
addArg(typedArg(arg, formal), formal)
540
- if ( methodType.isParamDependent && typeOfArg(arg).exists)
542
+ if methodType.isParamDependent && typeOfArg(arg).exists then
541
543
// `typeOfArg(arg)` could be missing because the evaluation of `arg` produced type errors
542
- safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg))
543
- else identity
544
- }
545
-
546
- def addTypedAndSubstitute (arg : Arg , formal : Type ): List [Type ] =
547
- val substParam = addTyped(arg, formal)
548
- formals1.mapconserve(substParam)
544
+ formals1.mapconserve(safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg)))
545
+ else
546
+ formals1
549
547
550
548
def missingArg (n : Int ): Unit = {
551
549
val pname = methodType.paramNames(n)
@@ -587,11 +585,11 @@ trait Applications extends Compatibility {
587
585
def implicitArg = implicitArgTree(formal, appPos.span)
588
586
589
587
if methodType.isContextualMethod && ctx.mode.is(Mode .ImplicitsEnabled ) then
590
- matchArgs(args1, addTypedAndSubstitute (treeToArg(implicitArg), formal), n + 1 )
588
+ matchArgs(args1, addTyped (treeToArg(implicitArg), formal), n + 1 )
591
589
else
592
590
val defaultArg = defaultExpr
593
591
if ! defaultArg.isEmpty then
594
- matchArgs(args1, addTypedAndSubstitute (treeToArg(defaultArg), formal), n + 1 )
592
+ matchArgs(args1, addTyped (treeToArg(defaultArg), formal), n + 1 )
595
593
else
596
594
missingArg(n)
597
595
}
@@ -613,7 +611,7 @@ trait Applications extends Compatibility {
613
611
case EmptyTree :: args1 =>
614
612
tryDefault(n, args1)
615
613
case arg :: args1 =>
616
- matchArgs(args1, addTypedAndSubstitute (arg, formal), n + 1 )
614
+ matchArgs(args1, addTyped (arg, formal), n + 1 )
617
615
case nil =>
618
616
tryDefault(n, args)
619
617
}
0 commit comments