Skip to content

Commit 520e548

Browse files
mbovelWojciechMazur
authored andcommitted
Type addImplicitsArgs result with the first failure
[Cherry-picked 0890e7a]
1 parent 0b8dc35 commit 520e548

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,7 +3833,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
38333833
case _ => ()
38343834

38353835
val args = implicitArgs(wtp.paramInfos, 0, pt)
3836-
if (args.tpes.exists(_.isInstanceOf[SearchFailureType])) {
3836+
val firstFailure = args.tpes.find(_.isInstanceOf[SearchFailureType])
3837+
if (firstFailure.isDefined) {
38373838
// If there are several arguments, some arguments might already
38383839
// have influenced the context, binding variables, but later ones
38393840
// might fail. In that case the constraint and instantiated variables
@@ -3866,10 +3867,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
38663867

38673868
retyped
38683869
else
3869-
val firstNonAmbiguous = args.tpes.find(tp => tp.isError && !tp.isInstanceOf[AmbiguousImplicits])
3870-
def firstError = args.tpes.find(_.isError)
3871-
val errorType = firstNonAmbiguous.orElse(firstError).getOrElse(NoType)
3872-
val res = untpd.Apply(tree, args).withType(errorType)
3870+
val res = untpd.Apply(tree, args).withType(firstFailure.get)
38733871
reportErrors(res, wtp)
38743872
res
38753873
}

0 commit comments

Comments
 (0)