Skip to content

Commit 8e4207e

Browse files
committed
[ConstraintSystem] NFC: Simplify type var producer/step by referencing constraint system from bindings
1 parent 22b34e8 commit 8e4207e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5857,8 +5857,7 @@ class TypeVarBindingProducer : public BindingProducer<TypeVariableBinding> {
58575857
public:
58585858
using Element = TypeVariableBinding;
58595859

5860-
TypeVarBindingProducer(ConstraintSystem &cs,
5861-
ConstraintSystem::PotentialBindings &bindings);
5860+
TypeVarBindingProducer(ConstraintSystem::PotentialBindings &bindings);
58625861

58635862
/// Retrieve a set of bindings available in the current state.
58645863
ArrayRef<Binding> getCurrentBindings() const { return Bindings; }

lib/Sema/CSStep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ StepResult ComponentStep::take(bool prevFailed) {
342342
(!disjunction || bestBindings->favoredOverDisjunction(disjunction))) {
343343
// Produce a type variable step.
344344
return suspend(
345-
std::make_unique<TypeVariableStep>(CS, *bestBindings, Solutions));
345+
std::make_unique<TypeVariableStep>(*bestBindings, Solutions));
346346
} else if (disjunction) {
347347
// Produce a disjunction step.
348348
return suspend(

lib/Sema/CSStep.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,10 @@ class TypeVariableStep final : public BindingStep<TypeVarBindingProducer> {
577577
bool SawFirstLiteralConstraint = false;
578578

579579
public:
580-
TypeVariableStep(ConstraintSystem &cs, BindingContainer &bindings,
580+
TypeVariableStep(BindingContainer &bindings,
581581
SmallVectorImpl<Solution> &solutions)
582-
: BindingStep(cs, {cs, bindings}, solutions), TypeVar(bindings.TypeVar) {}
582+
: BindingStep(bindings.CS, {bindings}, solutions),
583+
TypeVar(bindings.TypeVar) {}
583584

584585
void setup() override;
585586

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5332,8 +5332,8 @@ bool ConstraintSystem::isReadOnlyKeyPathComponent(
53325332
}
53335333

53345334
TypeVarBindingProducer::TypeVarBindingProducer(
5335-
ConstraintSystem &cs, ConstraintSystem::PotentialBindings &bindings)
5336-
: BindingProducer(cs, bindings.TypeVar->getImpl().getLocator()),
5335+
ConstraintSystem::PotentialBindings &bindings)
5336+
: BindingProducer(bindings.CS, bindings.TypeVar->getImpl().getLocator()),
53375337
TypeVar(bindings.TypeVar),
53385338
CanBeNil(llvm::any_of(bindings.Protocols, [](Constraint *constraint) {
53395339
auto *protocol = constraint->getProtocol();
@@ -5348,7 +5348,7 @@ TypeVarBindingProducer::TypeVarBindingProducer(
53485348
// this problem since its rooted in the fact that constraint system
53495349
// is under-constrained.
53505350
if (bindings.AssociatedCodeCompletionToken) {
5351-
locator = cs.getConstraintLocator(bindings.AssociatedCodeCompletionToken);
5351+
locator = CS.getConstraintLocator(bindings.AssociatedCodeCompletionToken);
53525352
}
53535353

53545354
Bindings.push_back(Binding::forHole(TypeVar, locator));

0 commit comments

Comments
 (0)