@@ -281,8 +281,7 @@ void ConstraintSystem::removeConversionRestriction(
281
281
282
282
void ConstraintSystem::addFix (ConstraintFix *fix) {
283
283
bool inserted = Fixes.insert (fix);
284
- if (!inserted)
285
- return ;
284
+ ASSERT (inserted);
286
285
287
286
if (solverState)
288
287
recordChange (SolverTrail::Change::addedFix (fix));
@@ -294,32 +293,23 @@ void ConstraintSystem::removeFix(ConstraintFix *fix) {
294
293
}
295
294
296
295
void 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);
306
299
307
- if (solverState) {
308
- recordChange (SolverTrail::Change::recordedDisjunctionChoice (
309
- locator, index));
310
- }
300
+ if (solverState)
301
+ recordChange (SolverTrail::Change::recordedDisjunctionChoice (locator, index));
311
302
}
312
303
313
304
void ConstraintSystem::recordAppliedDisjunction (
314
305
ConstraintLocator *locator, FunctionType *fnType) {
315
306
// 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));
323
313
}
324
314
325
315
// / Retrieve a dynamic result signature for the given declaration.
@@ -853,10 +843,10 @@ std::pair<Type, OpenedArchetypeType *> ConstraintSystem::openExistentialType(
853
843
void ConstraintSystem::recordOpenedExistentialType (
854
844
ConstraintLocator *locator, OpenedArchetypeType *opened) {
855
845
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));
860
850
}
861
851
862
852
GenericEnvironment *
@@ -894,12 +884,10 @@ ConstraintSystem::getPackElementEnvironment(ConstraintLocator *locator,
894
884
void ConstraintSystem::recordPackExpansionEnvironment (
895
885
ConstraintLocator *locator, std::pair<UUID, Type> uuidAndShape) {
896
886
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));
903
891
}
904
892
905
893
PackExpansionExpr *
@@ -910,12 +898,11 @@ ConstraintSystem::getPackEnvironment(PackElementExpr *packElement) const {
910
898
911
899
void ConstraintSystem::addPackEnvironment (PackElementExpr *packElement,
912
900
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));
919
906
}
920
907
921
908
// / Extend the given depth map by adding depths for all of the subexpressions
@@ -1028,7 +1015,8 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl,
1028
1015
openGeneric (decl->getDeclContext (), decl->getGenericSignature (), locator,
1029
1016
replacements);
1030
1017
1031
- recordOpenedTypes (locator, replacements);
1018
+ // FIXME: Get rid of fixmeAllowDuplicates.
1019
+ recordOpenedTypes (locator, replacements, /* fixmeAllowDuplicates=*/ true );
1032
1020
1033
1021
if (parentTy) {
1034
1022
const auto parentTyInContext =
@@ -1278,10 +1266,10 @@ Type ConstraintSystem::openPackExpansionType(PackExpansionType *expansion,
1278
1266
void ConstraintSystem::recordOpenedPackExpansionType (PackExpansionType *expansion,
1279
1267
TypeVariableType *expansionVar) {
1280
1268
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));
1285
1273
}
1286
1274
1287
1275
Type ConstraintSystem::openOpaqueType (OpaqueTypeArchetypeType *opaque,
@@ -1687,10 +1675,10 @@ Type ConstraintSystem::getUnopenedTypeOfReference(
1687
1675
void ConstraintSystem::recordOpenedType (
1688
1676
ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes) {
1689
1677
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));
1694
1682
}
1695
1683
1696
1684
void ConstraintSystem::removeOpenedType (ConstraintLocator *locator) {
@@ -1700,7 +1688,8 @@ void ConstraintSystem::removeOpenedType(ConstraintLocator *locator) {
1700
1688
1701
1689
void ConstraintSystem::recordOpenedTypes (
1702
1690
ConstraintLocatorBuilder locator,
1703
- const OpenedTypeMap &replacements) {
1691
+ const OpenedTypeMap &replacements,
1692
+ bool fixmeAllowDuplicates) {
1704
1693
if (replacements.empty ())
1705
1694
return ;
1706
1695
@@ -1721,7 +1710,10 @@ void ConstraintSystem::recordOpenedTypes(
1721
1710
OpenedType* openedTypes
1722
1711
= Allocator.Allocate <OpenedType>(replacements.size ());
1723
1712
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 (
1725
1717
locatorPtr, llvm::ArrayRef (openedTypes, replacements.size ()));
1726
1718
}
1727
1719
0 commit comments