Skip to content

Commit 6dd859e

Browse files
committed
[CSBindings] Remove remaining flags from inference
1 parent dff73c9 commit 6dd859e

File tree

2 files changed

+10
-33
lines changed

2 files changed

+10
-33
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -556,28 +556,15 @@ ConstraintSystem::inferBindingsFor(TypeVariableType *typeVar,
556556
typeVar, ConstraintGraph::GatheringKind::EquivalenceClass);
557557

558558
llvm::SmallPtrSet<CanType, 4> exactTypes;
559-
bool hasNonDependentMemberRelationalConstraints = false;
560-
bool hasDependentMemberRelationalConstraints = false;
561559

562560
for (auto *constraint : constraints) {
563-
bool failed = bindings.infer(*this, exactTypes, constraint,
564-
hasNonDependentMemberRelationalConstraints,
565-
hasDependentMemberRelationalConstraints);
561+
bool failed = bindings.infer(*this, exactTypes, constraint);
566562

567563
// Upon inference failure let's produce an empty set of bindings.
568564
if (failed)
569565
return {typeVar};
570566
}
571567

572-
// If there were both dependent-member and non-dependent-member relational
573-
// constraints, consider this "fully bound"; we don't want to touch it.
574-
if (hasDependentMemberRelationalConstraints) {
575-
if (hasNonDependentMemberRelationalConstraints)
576-
bindings.FullyBound = true;
577-
else
578-
bindings.Bindings.clear();
579-
}
580-
581568
if (finalize) {
582569
llvm::SmallDenseMap<TypeVariableType *, ConstraintSystem::PotentialBindings>
583570
inferred;
@@ -590,9 +577,7 @@ ConstraintSystem::inferBindingsFor(TypeVariableType *typeVar,
590577

591578
Optional<ConstraintSystem::PotentialBinding>
592579
ConstraintSystem::getPotentialBindingForRelationalConstraint(
593-
PotentialBindings &result, Constraint *constraint,
594-
bool &hasDependentMemberRelationalConstraints,
595-
bool &hasNonDependentMemberRelationalConstraints) const {
580+
PotentialBindings &result, Constraint *constraint) const {
596581
assert(constraint->getClassification() ==
597582
ConstraintClassification::Relational &&
598583
"only relational constraints handled here");
@@ -675,11 +660,11 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
675660
if (type->is<DependentMemberType>()) {
676661
if (!ConstraintSystem::typeVarOccursInType(typeVar, type,
677662
&result.InvolvesTypeVariables)) {
678-
hasDependentMemberRelationalConstraints = true;
663+
result.FullyBound = true;
679664
}
665+
680666
return None;
681667
}
682-
hasNonDependentMemberRelationalConstraints = true;
683668

684669
// If our binding choice is a function type and we're attempting
685670
// to bind to a type variable that is the result of opening a
@@ -751,8 +736,7 @@ ConstraintSystem::getPotentialBindingForRelationalConstraint(
751736
/// those types should be opened.
752737
bool ConstraintSystem::PotentialBindings::infer(
753738
const ConstraintSystem &cs, llvm::SmallPtrSetImpl<CanType> &exactTypes,
754-
Constraint *constraint, bool &hasNonDependentMemberRelationalConstraints,
755-
bool &hasDependentMemberRelationalConstraints) {
739+
Constraint *constraint) {
756740
switch (constraint->getKind()) {
757741
case ConstraintKind::Bind:
758742
case ConstraintKind::Equal:
@@ -777,9 +761,8 @@ bool ConstraintSystem::PotentialBindings::infer(
777761
constraint->getSecondType()->isEqual(TypeVar))
778762
PotentiallyIncomplete = true;
779763

780-
auto binding = cs.getPotentialBindingForRelationalConstraint(
781-
*this, constraint, hasDependentMemberRelationalConstraints,
782-
hasNonDependentMemberRelationalConstraints);
764+
auto binding =
765+
cs.getPotentialBindingForRelationalConstraint(*this, constraint);
783766
if (!binding)
784767
break;
785768

@@ -870,7 +853,6 @@ bool ConstraintSystem::PotentialBindings::infer(
870853
if (cs.getFixedTypeRecursive(constraint->getFirstType(), true)
871854
->getAs<TypeVariableType>() == TypeVar) {
872855
Defaults.push_back(constraint);
873-
hasNonDependentMemberRelationalConstraints = true;
874856
}
875857
break;
876858

@@ -904,7 +886,6 @@ bool ConstraintSystem::PotentialBindings::infer(
904886
// Record constraint where protocol requirement originated
905887
// this is useful to use for the binding later.
906888
Protocols.push_back(constraint);
907-
hasNonDependentMemberRelationalConstraints = true;
908889
break;
909890
}
910891

lib/Sema/ConstraintSystem.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,9 +4609,7 @@ class ConstraintSystem {
46094609
public:
46104610
bool infer(const ConstraintSystem &cs,
46114611
llvm::SmallPtrSetImpl<CanType> &exactTypes,
4612-
Constraint *constraint,
4613-
bool &hasNonDependentMemberRelationalConstraints,
4614-
bool &hasDependentMemberRelationalConstraints);
4612+
Constraint *constraint);
46154613

46164614
/// Finalize binding computation for this type variable by
46174615
/// inferring bindings from context e.g. transitive bindings.
@@ -4688,10 +4686,8 @@ class ConstraintSystem {
46884686

46894687
private:
46904688
Optional<ConstraintSystem::PotentialBinding>
4691-
getPotentialBindingForRelationalConstraint(
4692-
PotentialBindings &result, Constraint *constraint,
4693-
bool &hasDependentMemberRelationalConstraints,
4694-
bool &hasNonDependentMemberRelationalConstraints) const;
4689+
getPotentialBindingForRelationalConstraint(PotentialBindings &result,
4690+
Constraint *constraint) const;
46954691
PotentialBindings getPotentialBindings(TypeVariableType *typeVar) const;
46964692

46974693
/// Add a constraint to the constraint system.

0 commit comments

Comments
 (0)