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