@@ -281,8 +281,7 @@ void ConstraintSystem::removeConversionRestriction(
281281
282282void ConstraintSystem::addFix (ConstraintFix *fix) {
283283 bool inserted = Fixes.insert (fix);
284- if (!inserted)
285- return ;
284+ ASSERT (inserted);
286285
287286 if (solverState)
288287 recordChange (SolverTrail::Change::addedFix (fix));
@@ -294,32 +293,23 @@ void ConstraintSystem::removeFix(ConstraintFix *fix) {
294293}
295294
296295void ConstraintSystem::recordDisjunctionChoice (
297- ConstraintLocator *locator,
298- unsigned index) {
299- // We shouldn't ever register disjunction choices multiple times.
300- auto inserted = DisjunctionChoices.insert (
301- std::make_pair (locator, index));
302- if (!inserted.second ) {
303- ASSERT (inserted.first ->second == index);
304- return ;
305- }
296+ ConstraintLocator *locator, unsigned index) {
297+ bool inserted = DisjunctionChoices.insert ({locator, index}).second ;
298+ ASSERT (inserted);
306299
307- if (solverState) {
308- recordChange (SolverTrail::Change::recordedDisjunctionChoice (
309- locator, index));
310- }
300+ if (solverState)
301+ recordChange (SolverTrail::Change::recordedDisjunctionChoice (locator, index));
311302}
312303
313304void ConstraintSystem::recordAppliedDisjunction (
314305 ConstraintLocator *locator, FunctionType *fnType) {
315306 // We shouldn't ever register disjunction choices multiple times.
316- auto inserted = AppliedDisjunctions.insert (
317- std::make_pair (locator, fnType));
318- if (inserted.second ) {
319- if (solverState) {
320- recordChange (SolverTrail::Change::recordedAppliedDisjunction (locator));
321- }
322- }
307+ bool inserted = AppliedDisjunctions.insert (
308+ std::make_pair (locator, fnType)).second ;
309+ ASSERT (inserted);
310+
311+ if (solverState)
312+ recordChange (SolverTrail::Change::recordedAppliedDisjunction (locator));
323313}
324314
325315// / Retrieve a dynamic result signature for the given declaration.
@@ -853,10 +843,10 @@ std::pair<Type, OpenedArchetypeType *> ConstraintSystem::openExistentialType(
853843void ConstraintSystem::recordOpenedExistentialType (
854844 ConstraintLocator *locator, OpenedArchetypeType *opened) {
855845 bool inserted = OpenedExistentialTypes.insert ({locator, opened}).second ;
856- if (inserted) {
857- if (solverState)
858- recordChange ( SolverTrail::Change::recordedOpenedExistentialType (locator));
859- }
846+ ASSERT (inserted);
847+
848+ if (solverState)
849+ recordChange ( SolverTrail::Change::recordedOpenedExistentialType (locator));
860850}
861851
862852GenericEnvironment *
@@ -894,12 +884,10 @@ ConstraintSystem::getPackElementEnvironment(ConstraintLocator *locator,
894884void ConstraintSystem::recordPackExpansionEnvironment (
895885 ConstraintLocator *locator, std::pair<UUID, Type> uuidAndShape) {
896886 bool inserted = PackExpansionEnvironments.insert ({locator, uuidAndShape}).second ;
897- if (inserted) {
898- if (solverState) {
899- recordChange (
900- SolverTrail::Change::recordedPackExpansionEnvironment (locator));
901- }
902- }
887+ ASSERT (inserted);
888+
889+ if (solverState)
890+ recordChange (SolverTrail::Change::recordedPackExpansionEnvironment (locator));
903891}
904892
905893PackExpansionExpr *
@@ -910,12 +898,11 @@ ConstraintSystem::getPackEnvironment(PackElementExpr *packElement) const {
910898
911899void ConstraintSystem::addPackEnvironment (PackElementExpr *packElement,
912900 PackExpansionExpr *packExpansion) {
913- bool inserted =
914- PackEnvironments.insert ({packElement, packExpansion}).second ;
915- if (inserted) {
916- if (solverState)
917- recordChange (SolverTrail::Change::recordedPackEnvironment (packElement));
918- }
901+ bool inserted = PackEnvironments.insert ({packElement, packExpansion}).second ;
902+ ASSERT (inserted);
903+
904+ if (solverState)
905+ recordChange (SolverTrail::Change::recordedPackEnvironment (packElement));
919906}
920907
921908// / Extend the given depth map by adding depths for all of the subexpressions
@@ -1028,7 +1015,8 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl,
10281015 openGeneric (decl->getDeclContext (), decl->getGenericSignature (), locator,
10291016 replacements);
10301017
1031- recordOpenedTypes (locator, replacements);
1018+ // FIXME: Get rid of fixmeAllowDuplicates.
1019+ recordOpenedTypes (locator, replacements, /* fixmeAllowDuplicates=*/ true );
10321020
10331021 if (parentTy) {
10341022 const auto parentTyInContext =
@@ -1278,10 +1266,10 @@ Type ConstraintSystem::openPackExpansionType(PackExpansionType *expansion,
12781266void ConstraintSystem::recordOpenedPackExpansionType (PackExpansionType *expansion,
12791267 TypeVariableType *expansionVar) {
12801268 bool inserted = OpenedPackExpansionTypes.insert ({expansion, expansionVar}).second ;
1281- if (inserted) {
1282- if (solverState)
1283- recordChange ( SolverTrail::Change::recordedOpenedPackExpansionType (expansion));
1284- }
1269+ ASSERT (inserted);
1270+
1271+ if (solverState)
1272+ recordChange ( SolverTrail::Change::recordedOpenedPackExpansionType (expansion));
12851273}
12861274
12871275Type ConstraintSystem::openOpaqueType (OpaqueTypeArchetypeType *opaque,
@@ -1687,10 +1675,10 @@ Type ConstraintSystem::getUnopenedTypeOfReference(
16871675void ConstraintSystem::recordOpenedType (
16881676 ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes) {
16891677 bool inserted = OpenedTypes.insert ({locator, openedTypes}).second ;
1690- if (inserted) {
1691- if (solverState)
1692- recordChange ( SolverTrail::Change::recordedOpenedTypes (locator));
1693- }
1678+ ASSERT (inserted);
1679+
1680+ if (solverState)
1681+ recordChange ( SolverTrail::Change::recordedOpenedTypes (locator));
16941682}
16951683
16961684void ConstraintSystem::removeOpenedType (ConstraintLocator *locator) {
@@ -1700,7 +1688,8 @@ void ConstraintSystem::removeOpenedType(ConstraintLocator *locator) {
17001688
17011689void ConstraintSystem::recordOpenedTypes (
17021690 ConstraintLocatorBuilder locator,
1703- const OpenedTypeMap &replacements) {
1691+ const OpenedTypeMap &replacements,
1692+ bool fixmeAllowDuplicates) {
17041693 if (replacements.empty ())
17051694 return ;
17061695
@@ -1721,7 +1710,10 @@ void ConstraintSystem::recordOpenedTypes(
17211710 OpenedType* openedTypes
17221711 = Allocator.Allocate <OpenedType>(replacements.size ());
17231712 std::copy (replacements.begin (), replacements.end (), openedTypes);
1724- recordOpenedType (
1713+
1714+ // FIXME: Get rid of fixmeAllowDuplicates.
1715+ if (!fixmeAllowDuplicates || OpenedTypes.count (locatorPtr) == 0 )
1716+ recordOpenedType (
17251717 locatorPtr, llvm::ArrayRef (openedTypes, replacements.size ()));
17261718}
17271719
0 commit comments