Skip to content

Commit 8b5396b

Browse files
committed
[CSSolver] Attempt disabled disjunction choices only if they have a fix
This draws a distinction between disabled choices with and without fixes - former is disabled because it's unrelated, latter because it only makes sense to attempt it during "salvage" mode while trying to produce diagnostics.
1 parent be99082 commit 8b5396b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,10 @@ ConstraintSystem::filterDisjunction(
13051305
for (unsigned constraintIdx : indices(disjunction->getNestedConstraints())) {
13061306
auto constraint = disjunction->getNestedConstraints()[constraintIdx];
13071307

1308-
// Skip already-disabled constraints.
1309-
if (constraint->isDisabled())
1308+
// Skip already-disabled constraints. Let's treat disabled
1309+
// choices which have a fix as "enabled" ones here, so we can
1310+
// potentially infer some type information from them.
1311+
if (constraint->isDisabled() && !constraint->getFix())
13101312
continue;
13111313

13121314
if (pred(constraint)) {

lib/Sema/CSStep.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ StepResult DisjunctionStep::resume(bool prevFailed) {
430430
bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
431431
auto &ctx = CS.getASTContext();
432432

433-
if (choice.isDisabled()) {
433+
bool attemptFixes = CS.shouldAttemptFixes();
434+
// Enable "fixed" overload choices in "diagnostic" mode.
435+
if (!(attemptFixes && choice.hasFix()) && choice.isDisabled()) {
434436
if (isDebugMode()) {
435437
auto &log = getDebugLogger();
436438
log << "(skipping ";
@@ -442,7 +444,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
442444
}
443445

444446
// Skip unavailable overloads unless solver is in the "diagnostic" mode.
445-
if (!CS.shouldAttemptFixes() && choice.isUnavailable())
447+
if (!attemptFixes && choice.isUnavailable())
446448
return true;
447449

448450
if (ctx.LangOpts.DisableConstraintSolverPerformanceHacks)

0 commit comments

Comments
 (0)