Skip to content

Commit ad787a4

Browse files
committed
[ConstraintSystem] Extract "best disjunction" selection mechanism into a separate method
1 parent 91fccd8 commit ad787a4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5033,6 +5033,9 @@ class ConstraintSystem {
50335033
///
50345034
/// \returns The selected disjunction.
50355035
Constraint *selectDisjunction();
5036+
/// Select the best possible disjunction for solver to attempt
5037+
/// based on the given list.
5038+
Constraint *selectBestDisjunction(ArrayRef<Constraint *> disjunctions);
50365039

50375040
/// Pick a conjunction from the InactiveConstraints list.
50385041
///

lib/Sema/CSSolver.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,9 @@ ConstraintSystem::filterDisjunction(
16621662
// right-hand side of a conversion constraint, since having a concrete
16631663
// type that we're converting to can make it possible to split the
16641664
// constraint system into multiple ones.
1665-
static Constraint *selectBestBindingDisjunction(
1666-
ConstraintSystem &cs, SmallVectorImpl<Constraint *> &disjunctions) {
1665+
static Constraint *
1666+
selectBestBindingDisjunction(ConstraintSystem &cs,
1667+
ArrayRef<Constraint *> disjunctions) {
16671668

16681669
if (disjunctions.empty())
16691670
return nullptr;
@@ -2170,6 +2171,13 @@ Constraint *ConstraintSystem::selectDisjunction() {
21702171
if (disjunctions.empty())
21712172
return nullptr;
21722173

2174+
return selectBestDisjunction(disjunctions);
2175+
}
2176+
2177+
Constraint *
2178+
ConstraintSystem::selectBestDisjunction(ArrayRef<Constraint *> disjunctions) {
2179+
assert(!disjunctions.empty());
2180+
21732181
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
21742182
return disjunction;
21752183

0 commit comments

Comments
 (0)