Skip to content

Commit 321cc07

Browse files
committed
[CSBindings] Reset literal coverage when retracting constraint
1 parent 8e90882 commit 321cc07

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/swift/Sema/CSBindings.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ struct LiteralRequirement {
206206
bool canBeNil,
207207
DeclContext *useDC) const;
208208

209+
void resetCoverage() {
210+
assert(isCovered() && "literal requirement is uncovered");
211+
CoveredBy = nullptr;
212+
}
213+
209214
/// Determines whether literal protocol associated with this
210215
/// meta-information is viable for inclusion as a defaultable binding.
211216
bool viableAsBinding() const { return !isCovered() && hasDefaultType(); }

lib/Sema/CSBindings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,11 @@ void PotentialBindings::retract(Constraint *constraint) {
12981298
AdjacentVars.erase(std::make_pair(adjacentVar, constraint));
12991299
}
13001300

1301+
for (auto &literal : Literals) {
1302+
if (literal.second.CoveredBy == constraint)
1303+
literal.second.resetCoverage();
1304+
}
1305+
13011306
DelayedBy.erase(llvm::remove_if(DelayedBy, isMatchingConstraint),
13021307
DelayedBy.end());
13031308

0 commit comments

Comments
 (0)