Skip to content

Commit d4f5c72

Browse files
committed
[Constraint solver] Only build disjunctions when they're unsolved.
1 parent 7f66540 commit d4f5c72

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,12 @@ void ConstraintSystem::addOverloadSet(Type boundType,
13891389
OverloadChoice *favoredChoice) {
13901390
assert(!choices.empty() && "Empty overload set");
13911391

1392+
// If there is a single choice, add the bind overload directly.
1393+
if (choices.size() == 1) {
1394+
addBindOverloadConstraint(boundType, choices.front(), locator);
1395+
return;
1396+
}
1397+
13921398
SmallVector<Constraint *, 4> overloads;
13931399

13941400
// As we do for other favored constraints, if a favored overload has been

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ class ConstraintSystem {
14901490
if (isFavored)
14911491
constraint->setFavored();
14921492

1493-
addConstraint(constraint);
1493+
addUnsolvedConstraint(constraint);
14941494
}
14951495

14961496
/// Whether we should add a new constraint to capture a failure.

0 commit comments

Comments
 (0)