Skip to content

Commit a981a53

Browse files
committed
loosen some assertions
1 parent d741311 commit a981a53

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,28 +2584,28 @@ static void reconcileInverses(
25842584
SmallVector<InverseRequirement, 2> &inverses,
25852585
const DeclContext *baseContext,
25862586
std::optional<unsigned> inversesAlreadyMangledDepth) {
2587-
assert(baseContext);
2588-
25892587
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;
25982598

2599-
auto gp = inv.subject->castTo<GenericTypeParamType>();
2599+
auto gp = inv.subject->castTo<GenericTypeParamType>();
26002600

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;
26062606

2607-
return false;
2608-
});
2607+
return false;
2608+
});
26092609

26102610
// Sort inverse requirements for stability.
26112611
llvm::array_pod_sort(
@@ -3487,7 +3487,7 @@ void ASTMangler::appendGenericSignatureParts(
34873487

34883488
// Remember the depth to which inverses have just been appended.
34893489
assert(!inversesAlreadyMangledDepth
3490-
|| inversesAlreadyMangledDepth < inversesDepth);
3490+
|| inversesAlreadyMangledDepth <= inversesDepth);
34913491
inversesAlreadyMangledDepth = inversesDepth;
34923492

34933493
if (params.size() == 1 && params[0]->getDepth() == initialParamDepth)

0 commit comments

Comments
 (0)