Skip to content

Commit db460c9

Browse files
committed
Sema: Tighten invariant in ConstraintSystem::addConversionRestriction()
1 parent f381c29 commit db460c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ void ConstraintSystem::addConversionRestriction(
276276
Type srcType, Type dstType,
277277
ConversionRestrictionKind restriction) {
278278
auto key = std::make_pair(srcType.getPointer(), dstType.getPointer());
279-
bool inserted = ConstraintRestrictions.insert(
280-
std::make_pair(key, restriction)).second;
281-
if (!inserted)
279+
auto pair = ConstraintRestrictions.insert({key, restriction});
280+
if (!pair.second) {
281+
ASSERT(pair.first->second == restriction);
282282
return;
283+
}
283284

284285
if (solverState) {
285286
recordChange(SolverTrail::Change::AddedConversionRestriction(

0 commit comments

Comments
 (0)