Skip to content

Commit 7bebb00

Browse files
committed
AST: Small cleanup for ASTContext::getOverrideGenericSignature()
1 parent 51d7d6a commit 7bebb00

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

lib/AST/ASTContext.cpp

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,42 +4354,28 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
43544354
auto derivedGenericCtx = derived->getAsGenericContext();
43554355
auto &ctx = base->getASTContext();
43564356

4357-
if (!baseGenericCtx) {
4357+
if (!baseGenericCtx || !derivedGenericCtx)
43584358
return nullptr;
4359-
}
43604359

43614360
auto baseClass = base->getDeclContext()->getSelfClassDecl();
4362-
4363-
if (!baseClass) {
4361+
if (!baseClass)
43644362
return nullptr;
4365-
}
43664363

43674364
auto derivedClass = derived->getDeclContext()->getSelfClassDecl();
4368-
auto baseClassSig = baseClass->getGenericSignature();
4369-
4370-
if (!derivedClass) {
4365+
if (!derivedClass)
43714366
return nullptr;
4372-
}
43734367

4374-
if (derivedClass->getSuperclass().isNull()) {
4368+
if (derivedClass->getSuperclass().isNull())
43754369
return nullptr;
4376-
}
43774370

4378-
if (!derivedGenericCtx || !derivedGenericCtx->isGeneric()) {
4371+
if (baseGenericCtx->getGenericSignature().isNull() ||
4372+
derivedGenericCtx->getGenericSignature().isNull())
43794373
return nullptr;
4380-
}
4381-
4382-
if (derivedClass->getGenericSignature().isNull() &&
4383-
!baseGenericCtx->isGeneric()) {
4384-
return nullptr;
4385-
}
43864374

4375+
auto baseClassSig = baseClass->getGenericSignature();
43874376
auto subMap = derivedClass->getSuperclass()->getContextSubstitutionMap(
43884377
derivedClass->getModuleContext(), baseClass);
43894378

4390-
if (baseGenericCtx->getGenericSignature().isNull()) {
4391-
return nullptr;
4392-
}
43934379
unsigned derivedDepth = 0;
43944380

43954381
auto key = OverrideSignatureKey(baseGenericCtx->getGenericSignature(),
@@ -4405,9 +4391,11 @@ ASTContext::getOverrideGenericSignature(const ValueDecl *base,
44054391
derivedDepth = derivedSig->getGenericParams().back()->getDepth() + 1;
44064392

44074393
SmallVector<GenericTypeParamType *, 2> addedGenericParams;
4408-
for (auto gp : *derivedGenericCtx->getGenericParams()) {
4409-
addedGenericParams.push_back(
4410-
gp->getDeclaredInterfaceType()->castTo<GenericTypeParamType>());
4394+
if (auto *gpList = derivedGenericCtx->getGenericParams()) {
4395+
for (auto gp : *gpList) {
4396+
addedGenericParams.push_back(
4397+
gp->getDeclaredInterfaceType()->castTo<GenericTypeParamType>());
4398+
}
44114399
}
44124400

44134401
unsigned baseDepth = 0;

0 commit comments

Comments
 (0)