@@ -533,15 +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
- }
544
+ formals1.mapconserve( safeSubstParam(_, methodType.paramRefs(n), typeOfArg(arg) ))
545
+ else
546
+ formals1
545
547
546
548
def missingArg (n : Int ): Unit = {
547
549
val pname = methodType.paramNames(n)
@@ -553,7 +555,7 @@ trait Applications extends Compatibility {
553
555
def tryDefault (n : Int , args1 : List [Arg ]): Unit = {
554
556
val sym = methRef.symbol
555
557
556
- val defaultExpr =
558
+ val defaultArg =
557
559
if (isJavaAnnotConstr(sym)) {
558
560
val cinfo = sym.owner.asClass.classInfo
559
561
val pname = methodType.paramNames(n)
@@ -580,10 +582,12 @@ trait Applications extends Compatibility {
580
582
EmptyTree
581
583
}
582
584
583
- if (! defaultExpr.isEmpty) {
584
- val substParam = addTyped(treeToArg(defaultExpr), formal)
585
- matchArgs(args1, formals1.mapconserve(substParam), n + 1 )
586
- }
585
+ def implicitArg = implicitArgTree(formal, appPos.span)
586
+
587
+ if ! defaultArg.isEmpty then
588
+ matchArgs(args1, addTyped(treeToArg(defaultArg), formal), n + 1 )
589
+ else if methodType.isContextualMethod && ctx.mode.is(Mode .ImplicitsEnabled ) then
590
+ matchArgs(args1, addTyped(treeToArg(implicitArg), formal), n + 1 )
587
591
else
588
592
missingArg(n)
589
593
}
@@ -605,8 +609,7 @@ trait Applications extends Compatibility {
605
609
case EmptyTree :: args1 =>
606
610
tryDefault(n, args1)
607
611
case arg :: args1 =>
608
- val substParam = addTyped(arg, formal)
609
- matchArgs(args1, formals1.mapconserve(substParam), n + 1 )
612
+ matchArgs(args1, addTyped(arg, formal), n + 1 )
610
613
case nil =>
611
614
tryDefault(n, args)
612
615
}
@@ -1674,10 +1677,7 @@ trait Applications extends Compatibility {
1674
1677
pt match
1675
1678
case pt : FunProto =>
1676
1679
if pt.applyKind == ApplyKind .Using then
1677
- val alts0 = alts.filterConserve { alt =>
1678
- val mt = alt.widen.stripPoly
1679
- mt.isImplicitMethod || mt.isContextualMethod
1680
- }
1680
+ val alts0 = alts.filterConserve(_.widen.stripPoly.isImplicitMethod)
1681
1681
if alts0 ne alts then return resolve(alts0)
1682
1682
else if alts.exists(_.widen.stripPoly.isContextualMethod) then
1683
1683
return resolveMapped(alts, alt => stripImplicit(alt.widen), pt)
0 commit comments