Skip to content

Commit da32f0f

Browse files
committed
Use getSuperclassForDecl
1 parent 94a9a9a commit da32f0f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/IRGen/GenKeyPath.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -838,19 +838,13 @@ emitKeyPathComponent(IRGenModule &IGM,
838838
// different ways we need to go about this.
839839
if (loweredBaseTy.getClassOrBoundGenericClass()) {
840840

841-
// Walk up the class hierarchy to find the class decl that matches the
842-
// property's class decl and use this type to determin the field access.
841+
// Use the property's class type to determine the field access.
843842
auto propertyBaseDecl = property->getDeclContext()->getSelfClassDecl();
844-
auto currentBaseTy = loweredBaseTy.getASTType();
845-
while (currentBaseTy->getClassOrBoundGenericClass() != propertyBaseDecl &&
846-
currentBaseTy->getClassOrBoundGenericClass()->hasSuperclass()) {
847-
currentBaseTy = currentBaseTy->getClassOrBoundGenericClass()
848-
->getSuperclass()
849-
->getCanonicalType();
850-
}
843+
auto currentBaseTy =
844+
loweredBaseTy.getASTType()->getSuperclassForDecl(propertyBaseDecl);
851845
assert(currentBaseTy->getClassOrBoundGenericClass() == propertyBaseDecl);
852-
loweredBaseTy = IGM.getLoweredType(AbstractionPattern::getOpaque(),
853-
currentBaseTy->getWithoutSpecifierType());
846+
loweredBaseTy =
847+
IGM.getLoweredType(AbstractionPattern::getOpaque(), currentBaseTy);
854848

855849
switch (getClassFieldAccess(IGM, loweredBaseTy, property)) {
856850
case FieldAccess::ConstantDirect: {

0 commit comments

Comments
 (0)