Skip to content

Commit 41fb24d

Browse files
committed
Simplify propagatedFailure
1 parent cba1cfc commit 41fb24d

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3849,22 +3849,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
38493849
end implicitArgs
38503850

38513851
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)
38683855

38693856
def issueErrors(): Tree = {
38703857
def paramSymWithMethodTree(paramName: TermName) =
@@ -3897,8 +3884,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
38973884
// need to be reset.
38983885
ctx.typerState.resetTo(saved)
38993886

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.
39023890
if hasDefaultParams && !propFail.isInstanceOf[AmbiguousImplicits] then
39033891
val namedArgs = wtp.paramNames.lazyZip(args).flatMap { (pname, arg) =>
39043892
if (arg.tpe.isError) Nil else untpd.NamedArg(pname, untpd.TypedSplice(arg)) :: Nil

0 commit comments

Comments
 (0)