mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Constraint solver] Move tryOptimizeGenericDisjunction() into partitioning
This narrow favoring rule makes more sense as part of disjunction partitioning, because it is not dependent on the use site at all and should only kick in when other options fail.
This commit is contained in:
@@ -5036,34 +5036,6 @@ retry_after_fail:
|
||||
break;
|
||||
}
|
||||
|
||||
// Collect the active overload choices.
|
||||
SmallVector<OverloadChoice, 4> choices;
|
||||
for (auto constraint : disjunction->getNestedConstraints()) {
|
||||
if (constraint->isDisabled())
|
||||
continue;
|
||||
choices.push_back(constraint->getOverloadChoice());
|
||||
}
|
||||
|
||||
// If we can favor one generic result over another, do so.
|
||||
if (auto favoredChoice = tryOptimizeGenericDisjunction(choices)) {
|
||||
unsigned favoredIndex = favoredChoice - choices.data();
|
||||
for (auto constraint : disjunction->getNestedConstraints()) {
|
||||
if (constraint->isDisabled())
|
||||
continue;
|
||||
|
||||
if (favoredIndex == 0) {
|
||||
if (solverState)
|
||||
solverState->favorConstraint(constraint);
|
||||
else
|
||||
constraint->setFavored();
|
||||
|
||||
break;
|
||||
} else {
|
||||
--favoredIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there was a constraint that we couldn't reason about, don't use the
|
||||
// results of any common-type computations.
|
||||
if (hasUnhandledConstraints)
|
||||
|
||||
Reference in New Issue
Block a user