Skip to content

Commit 02129f2

Browse files
committed
Sema: Pull call to inferTransitiveBindings() out of BindingSet::finalize()
1 parent eede7e4 commit 02129f2

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

include/swift/Sema/CSBindings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class BindingSet {
565565
///
566566
/// \returns true if finalization successful (which makes binding set viable),
567567
/// and false otherwise.
568-
bool finalize(bool transitive);
568+
bool finalize();
569569

570570
static BindingScore formBindingScore(const BindingSet &b);
571571

lib/Sema/CSBindings.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,7 @@ static Type getKeyPathType(ASTContext &ctx, KeyPathCapability capability,
699699
return keyPathTy;
700700
}
701701

702-
bool BindingSet::finalize(bool transitive) {
703-
if (transitive)
704-
inferTransitiveBindings();
705-
702+
bool BindingSet::finalize() {
706703
if (auto *locator = TypeVar->getImpl().getLocator()) {
707704
if (TypeVar->getImpl().isKeyPathType()) {
708705
auto &ctx = CS.getASTContext();
@@ -1195,7 +1192,9 @@ std::optional<BindingSet> ConstraintSystem::determineBestBindings(
11951192
// produce a default type.
11961193
bool isViable = isViableForRanking(bindings);
11971194

1198-
if (!bindings.finalize(true))
1195+
bindings.inferTransitiveBindings();
1196+
1197+
if (!bindings.finalize())
11991198
continue;
12001199

12011200
bindings.determineLiteralCoverage();
@@ -1596,7 +1595,7 @@ BindingSet ConstraintSystem::getBindingsFor(TypeVariableType *typeVar) {
15961595
assert(!typeVar->getImpl().getFixedType(nullptr) && "has a fixed type");
15971596

15981597
BindingSet bindings(*this, typeVar, CG[typeVar].getPotentialBindings());
1599-
bindings.finalize(false);
1598+
bindings.finalize();
16001599
bindings.determineLiteralCoverage();
16011600

16021601
return bindings;

unittests/Sema/BindingInferenceTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ TEST_F(SemaTest, TestIntLiteralBindingInference) {
125125

126126
cs.getConstraintGraph()[floatLiteralTy].initBindingSet();
127127

128-
bindings.finalize(/*transitive=*/true);
128+
bindings.inferTransitiveBindings();
129+
bindings.finalize();
129130
bindings.determineLiteralCoverage();
130131

131132
// Inferred a single transitive binding through `$T_float`.

unittests/Sema/SemaFixture.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ BindingSet SemaTest::inferBindings(ConstraintSystem &cs,
141141

142142
auto &bindings = node.getBindingSet();
143143
bindings.inferTransitiveProtocolRequirements();
144-
bindings.finalize(/*transitive=*/true);
144+
bindings.inferTransitiveBindings();
145+
bindings.finalize();
145146
bindings.determineLiteralCoverage();
146147
}
147148

0 commit comments

Comments
 (0)