@@ -3849,22 +3849,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3849
3849
end implicitArgs
3850
3850
3851
3851
val args = implicitArgs(wtp.paramInfos, 0 , pt)
3852
-
3853
- def propagatedFailure (args : List [Tree ]): Type = args match {
3854
- case arg :: args1 =>
3855
- arg.tpe match {
3856
- case ambi : AmbiguousImplicits =>
3857
- propagatedFailure(args1) match {
3858
- case NoType | (_ : AmbiguousImplicits ) => ambi
3859
- case failed => failed
3860
- }
3861
- case failed : SearchFailureType => failed
3862
- case _ => propagatedFailure(args1)
3863
- }
3864
- case Nil => NoType
3865
- }
3866
-
3867
- val propFail = propagatedFailure(args)
3852
+ val firstNonAmbiguous = args.tpes.find(tp => tp.isError && ! tp.isInstanceOf [AmbiguousImplicits ])
3853
+ def firstError = args.tpes.find(_.isError)
3854
+ val propFail = firstNonAmbiguous.orElse(firstError).getOrElse(NoType )
3868
3855
3869
3856
def issueErrors (): Tree = {
3870
3857
def paramSymWithMethodTree (paramName : TermName ) =
@@ -3897,8 +3884,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3897
3884
// need to be reset.
3898
3885
ctx.typerState.resetTo(saved)
3899
3886
3900
- // If method has default params, fall back to regular application
3901
- // where all inferred implicits are passed as named args.
3887
+ // If method has default params and there are no "Ambiguous implicits"
3888
+ // error, fall back to regular application where all inferred
3889
+ // implicits are passed as named args.
3902
3890
if hasDefaultParams && ! propFail.isInstanceOf [AmbiguousImplicits ] then
3903
3891
val namedArgs = wtp.paramNames.lazyZip(args).flatMap { (pname, arg) =>
3904
3892
if (arg.tpe.isError) Nil else untpd.NamedArg (pname, untpd.TypedSplice (arg)) :: Nil
0 commit comments