Skip to content

Commit 7bbe589

Browse files
committed
[CSStep] Remove disjunction pruning logic from DisjunctionStep
Since old favoring mechanism has been removed this is dead code now because nothing is going to equate disjunction constraints.
1 parent 3ac1026 commit 7bbe589

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

lib/Sema/CSStep.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,6 @@ class TypeVariableStep final : public BindingStep<TypeVarBindingProducer> {
677677

678678
class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
679679
Constraint *Disjunction;
680-
SmallVector<Constraint *, 4> DisabledChoices;
681680
ConstraintList::iterator AfterDisjunction;
682681

683682
Optional<Score> BestNonGenericScore;
@@ -696,7 +695,6 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
696695
: BindingStep(cs, {cs, disjunction, favoredChoices}, solutions),
697696
Disjunction(disjunction), AfterDisjunction(erase(disjunction)) {
698697
assert(Disjunction->getKind() == ConstraintKind::Disjunction);
699-
pruneOverloadSet(Disjunction);
700698
++cs.solverState->NumDisjunctions;
701699
}
702700

@@ -705,9 +703,6 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
705703
ActiveChoice.reset();
706704
// Return disjunction constraint back to the system.
707705
restore(AfterDisjunction, Disjunction);
708-
// Re-enable previously disabled overload choices.
709-
for (auto *choice : DisabledChoices)
710-
choice->setEnabled();
711706
}
712707

713708
StepResult resume(bool prevFailed) override;
@@ -760,46 +755,6 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
760755
/// simplified further, false otherwise.
761756
bool attempt(const DisjunctionChoice &choice) override;
762757

763-
// Check if selected disjunction has a representative
764-
// this might happen when there are multiple binary operators
765-
// chained together. If so, disable choices which differ
766-
// from currently selected representative.
767-
void pruneOverloadSet(Constraint *disjunction) {
768-
auto *choice = disjunction->getNestedConstraints().front();
769-
if (choice->getKind() != ConstraintKind::BindOverload)
770-
return;
771-
772-
auto *typeVar = choice->getFirstType()->getAs<TypeVariableType>();
773-
if (!typeVar)
774-
return;
775-
776-
auto *repr = typeVar->getImpl().getRepresentative(nullptr);
777-
if (!repr || repr == typeVar)
778-
return;
779-
780-
for (auto overload : CS.getResolvedOverloads()) {
781-
auto resolved = overload.second;
782-
if (!resolved.boundType->isEqual(repr))
783-
continue;
784-
785-
auto &representative = resolved.choice;
786-
if (!representative.isDecl())
787-
return;
788-
789-
// Disable all of the overload choices which are different from
790-
// the one which is currently picked for representative.
791-
for (auto *constraint : disjunction->getNestedConstraints()) {
792-
auto choice = constraint->getOverloadChoice();
793-
if (!choice.isDecl() || choice.getDecl() == representative.getDecl())
794-
continue;
795-
796-
constraint->setDisabled();
797-
DisabledChoices.push_back(constraint);
798-
}
799-
break;
800-
}
801-
};
802-
803758
// Figure out which of the solutions has the smallest score.
804759
static Optional<Score> getBestScore(SmallVectorImpl<Solution> &solutions) {
805760
if (solutions.empty())

0 commit comments

Comments
 (0)