Skip to content

Commit 91fccd8

Browse files
committed
[ConstraintSystem] Record all disjunctions selected along the current path
1 parent 2e4a010 commit 91fccd8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ class ConstraintSystem {
22512251
friend class SplitterStep;
22522252
friend class ComponentStep;
22532253
friend class TypeVariableStep;
2254+
friend class DisjunctionStep;
22542255
friend class ConjunctionStep;
22552256
friend class ConjunctionElement;
22562257
friend class RequirementFailure;
@@ -2402,6 +2403,10 @@ class ConstraintSystem {
24022403
/// the current constraint system.
24032404
llvm::MapVector<ConstraintLocator *, unsigned> DisjunctionChoices;
24042405

2406+
/// The stack of all disjunctions selected during current path in order.
2407+
/// This stack is managed by the \c DisjunctionStep.
2408+
llvm::SmallVector<Constraint *, 4> SelectedDisjunctions;
2409+
24052410
/// A map from applied disjunction constraints to the corresponding
24062411
/// argument function type.
24072412
llvm::SmallMapVector<ConstraintLocator *, const FunctionType *, 4>

lib/Sema/CSStep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
653653
assert(Disjunction->getKind() == ConstraintKind::Disjunction);
654654
pruneOverloadSet(Disjunction);
655655
++cs.solverState->NumDisjunctions;
656+
cs.SelectedDisjunctions.push_back(Disjunction);
656657
}
657658

658659
~DisjunctionStep() override {
@@ -663,6 +664,8 @@ class DisjunctionStep final : public BindingStep<DisjunctionChoiceProducer> {
663664
// Re-enable previously disabled overload choices.
664665
for (auto *choice : DisabledChoices)
665666
choice->setEnabled();
667+
668+
CS.SelectedDisjunctions.pop_back();
666669
}
667670

668671
StepResult resume(bool prevFailed) override;

0 commit comments

Comments
 (0)