@@ -2584,28 +2584,28 @@ static void reconcileInverses(
2584
2584
SmallVector<InverseRequirement, 2 > &inverses,
2585
2585
const DeclContext *baseContext,
2586
2586
std::optional<unsigned > inversesAlreadyMangledDepth) {
2587
- assert (baseContext);
2588
-
2589
2587
CanGenericSignature childSig;
2590
- if (auto sig = baseContext->getGenericSignatureOfContext ())
2591
- childSig = sig.getCanonicalSignature ();
2592
-
2593
- llvm::erase_if (inverses, [&](InverseRequirement const & inv) -> bool {
2594
- // Drop inverses that aren't applicable in the nested / child signature,
2595
- // because of an added requirement.
2596
- if (childSig && childSig->requiresProtocol (inv.subject , inv.protocol ))
2597
- return true ;
2588
+ if (baseContext)
2589
+ if (auto sig = baseContext->getGenericSignatureOfContext ())
2590
+ childSig = sig.getCanonicalSignature ();
2591
+
2592
+ if (childSig || inversesAlreadyMangledDepth)
2593
+ llvm::erase_if (inverses, [&](InverseRequirement const & inv) -> bool {
2594
+ // Drop inverses that aren't applicable in the nested / child signature,
2595
+ // because of an added requirement.
2596
+ if (childSig && childSig->requiresProtocol (inv.subject , inv.protocol ))
2597
+ return true ;
2598
2598
2599
- auto gp = inv.subject ->castTo <GenericTypeParamType>();
2599
+ auto gp = inv.subject ->castTo <GenericTypeParamType>();
2600
2600
2601
- // Remove inverses that were either already mangled for this entity,
2602
- // or chosen not to be included in the output.
2603
- if (auto limit = inversesAlreadyMangledDepth)
2604
- if (gp->getDepth () <= limit)
2605
- return true ;
2601
+ // Remove inverses that were either already mangled for this entity,
2602
+ // or chosen not to be included in the output.
2603
+ if (auto limit = inversesAlreadyMangledDepth)
2604
+ if (gp->getDepth () <= limit)
2605
+ return true ;
2606
2606
2607
- return false ;
2608
- });
2607
+ return false ;
2608
+ });
2609
2609
2610
2610
// Sort inverse requirements for stability.
2611
2611
llvm::array_pod_sort (
@@ -3487,7 +3487,7 @@ void ASTMangler::appendGenericSignatureParts(
3487
3487
3488
3488
// Remember the depth to which inverses have just been appended.
3489
3489
assert (!inversesAlreadyMangledDepth
3490
- || inversesAlreadyMangledDepth < inversesDepth);
3490
+ || inversesAlreadyMangledDepth <= inversesDepth);
3491
3491
inversesAlreadyMangledDepth = inversesDepth;
3492
3492
3493
3493
if (params.size () == 1 && params[0 ]->getDepth () == initialParamDepth)
0 commit comments