Skip to content

Commit ab72c53

Browse files
committed
Sema: Split off inferTransitiveKeyPathBindings() from BindingSet::inferTransitiveBindings()
1 parent 19a2eeb commit ab72c53

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

include/swift/Sema/CSBindings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ class BindingSet {
551551
/// variables in the workset.
552552
void inferTransitiveBindings();
553553

554+
void inferTransitiveKeyPathBindings();
555+
554556
/// Detect subtype, conversion or equivalence relationship
555557
/// between two type variables and attempt to propagate protocol
556558
/// requirements down the subtype or equivalence chain.

lib/Sema/CSBindings.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,7 @@ void BindingSet::inferTransitiveProtocolRequirements() {
493493
} while (!workList.empty());
494494
}
495495

496-
void BindingSet::inferTransitiveBindings() {
497-
using BindingKind = AllowedBindingKind;
498-
496+
void BindingSet::inferTransitiveKeyPathBindings() {
499497
// If the current type variable represents a key path root type
500498
// let's try to transitively infer its type through bindings of
501499
// a key path type.
@@ -550,14 +548,18 @@ void BindingSet::inferTransitiveBindings() {
550548
}
551549
} else {
552550
addBinding(
553-
binding.withSameSource(inferredRootTy, BindingKind::Exact),
551+
binding.withSameSource(inferredRootTy, AllowedBindingKind::Exact),
554552
/*isTransitive=*/true);
555553
}
556554
}
557555
}
558556
}
559557
}
560558
}
559+
}
560+
561+
void BindingSet::inferTransitiveBindings() {
562+
inferTransitiveKeyPathBindings();
561563

562564
for (const auto &entry : Info.SupertypeOf) {
563565
auto &node = CS.getConstraintGraph()[entry.first];
@@ -608,8 +610,8 @@ void BindingSet::inferTransitiveBindings() {
608610
// either be Exact or Supertypes in order for it to make sense
609611
// to add Supertype bindings based on the relationship between
610612
// our type variables.
611-
if (binding.Kind != BindingKind::Exact &&
612-
binding.Kind != BindingKind::Supertypes)
613+
if (binding.Kind != AllowedBindingKind::Exact &&
614+
binding.Kind != AllowedBindingKind::Supertypes)
613615
continue;
614616

615617
auto type = binding.BindingType;
@@ -620,7 +622,7 @@ void BindingSet::inferTransitiveBindings() {
620622
if (ConstraintSystem::typeVarOccursInType(TypeVar, type))
621623
continue;
622624

623-
addBinding(binding.withSameSource(type, BindingKind::Supertypes),
625+
addBinding(binding.withSameSource(type, AllowedBindingKind::Supertypes),
624626
/*isTransitive=*/true);
625627
}
626628
}

0 commit comments

Comments
 (0)