Skip to content

Commit 009fd94

Browse files
Merge pull request #78285 from AnthonyLatsis/musa-acuminata
TypeCheckType: Minor `resolveTypeInContext` simplification
2 parents c347b66 + f6f71fe commit 009fd94

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,17 @@ Type TypeResolution::resolveTypeInContext(TypeDecl *typeDecl,
449449
for (auto *parentDC = fromDC; !parentDC->isModuleScopeContext();
450450
parentDC = parentDC->getParentForLookup()) {
451451
auto *parentNominal = parentDC->getSelfNominalTypeDecl();
452+
if (!parentNominal) {
453+
continue;
454+
}
455+
452456
if (parentNominal == nominalType)
453457
return parentDC->getDeclaredInterfaceType();
454-
if (isa<ExtensionDecl>(parentDC)) {
455-
auto *extendedType = parentNominal;
456-
while (extendedType != nullptr) {
457-
if (extendedType == nominalType)
458-
return extendedType->getDeclaredInterfaceType();
459-
extendedType = extendedType->getParent()->getSelfNominalTypeDecl();
460-
}
461-
}
458+
459+
// `parentDC` is either a nominal or an extension thereof. Either way,
460+
// continue climbing up the nominal. Do not to climb up an extension
461+
// because they are not allowed to be nested.
462+
parentDC = parentNominal;
462463
}
463464
}
464465

0 commit comments

Comments
 (0)