Skip to content

Commit 2c44e37

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 11b897b commit 2c44e37

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

lib/Sema/CSStep.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,6 @@ class TypeVariableStep final : public BindingStep<TypeVarBindingProducer> {
671671

672672
class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
673673
Constraint *Disjunction;
674-
SmallVector<Constraint *, 4> DisabledChoices;
675-
676674
std::optional<Score> BestNonGenericScore;
677675
std::optional<std::pair<Constraint *, Score>> LastSolvedChoice;
678676

@@ -689,16 +687,12 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
689687
: BindingStep(cs, {cs, disjunction, favoredChoices}, solutions),
690688
Disjunction(disjunction) {
691689
assert(Disjunction->getKind() == ConstraintKind::Disjunction);
692-
pruneOverloadSet(Disjunction);
693690
++cs.solverState->NumDisjunctions;
694691
}
695692

696693
~DisjunctionStep() override {
697694
// Rewind back any changes left after attempting last choice.
698695
ActiveChoice.reset();
699-
// Re-enable previously disabled overload choices.
700-
for (auto *choice : DisabledChoices)
701-
choice->setEnabled();
702696
}
703697

704698
StepResult resume(bool prevFailed) override;
@@ -751,46 +745,6 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
751745
/// simplified further, false otherwise.
752746
bool attempt(const DisjunctionChoice &choice) override;
753747

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

0 commit comments

Comments
 (0)