Skip to content

Commit be470f5

Browse files
committed
[ConstraintSystem] Don't attempt to optimize disjunction in diagnostic mode
Don't attempt disjunction optimization in "diagnostic mode" because in such mode we'd like to attempt all of the available overloads regardless of of problems related to missing or extraneous labels and/or arguments.
1 parent 8b33cd0 commit be470f5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6072,14 +6072,20 @@ ConstraintSystem::simplifyApplicableFnConstraint(
60726072

60736073
};
60746074

6075-
// If the right-hand side is a type variable, try to simplify the overload
6076-
// set.
6077-
if (auto typeVar = desugar2->getAs<TypeVariableType>()) {
6078-
Type newType2 = simplifyAppliedOverloads(typeVar, func1, locator);
6079-
if (!newType2)
6080-
return SolutionKind::Error;
6075+
// Don't attempt this optimization in "diagnostic mode" because
6076+
// in such mode we'd like to attempt all of the available
6077+
// overloads regardless of of problems related to missing or
6078+
// extraneous labels and/or arguments.
6079+
if (!(solverState && shouldAttemptFixes())) {
6080+
// If the right-hand side is a type variable,
6081+
// try to simplify the overload set.
6082+
if (auto typeVar = desugar2->getAs<TypeVariableType>()) {
6083+
Type newType2 = simplifyAppliedOverloads(typeVar, func1, locator);
6084+
if (!newType2)
6085+
return SolutionKind::Error;
60816086

6082-
desugar2 = newType2->getDesugaredType();
6087+
desugar2 = newType2->getDesugaredType();
6088+
}
60836089
}
60846090

60856091
// If right-hand side is a type variable, the constraint is unsolved.

0 commit comments

Comments
 (0)