Skip to content

Commit

Permalink
Merge pull request #78285 from AnthonyLatsis/musa-acuminata
Browse files Browse the repository at this point in the history
TypeCheckType: Minor `resolveTypeInContext` simplification
  • Loading branch information
AnthonyLatsis authored Dec 19, 2024
2 parents c347b66 + f6f71fe commit 009fd94
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,17 @@ Type TypeResolution::resolveTypeInContext(TypeDecl *typeDecl,
for (auto *parentDC = fromDC; !parentDC->isModuleScopeContext();
parentDC = parentDC->getParentForLookup()) {
auto *parentNominal = parentDC->getSelfNominalTypeDecl();
if (!parentNominal) {
continue;
}

if (parentNominal == nominalType)
return parentDC->getDeclaredInterfaceType();
if (isa<ExtensionDecl>(parentDC)) {
auto *extendedType = parentNominal;
while (extendedType != nullptr) {
if (extendedType == nominalType)
return extendedType->getDeclaredInterfaceType();
extendedType = extendedType->getParent()->getSelfNominalTypeDecl();
}
}

// `parentDC` is either a nominal or an extension thereof. Either way,
// continue climbing up the nominal. Do not to climb up an extension
// because they are not allowed to be nested.
parentDC = parentNominal;
}
}

Expand Down

0 comments on commit 009fd94

Please sign in to comment.