Skip to content

Commit 30cd0a9

Browse files
committed
AST: Update TypeBase::getSuperclass() for subclass existentials
The "superclass" of a subclass existential is the superclass constraint. This makes a bunch of random things work, but is somewhat unprincipled. It fits with how we already handle class-constrained archetypes and DynamicSelfType, though.
1 parent ad417c9 commit 30cd0a9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/AST/Type.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,11 @@ Type TypeBase::getSuperclass(LazyResolver *resolver) {
15741574
if (auto dynamicSelfTy = getAs<DynamicSelfType>())
15751575
return dynamicSelfTy->getSelfType();
15761576

1577+
if (auto compositionTy = getAs<ProtocolCompositionType>())
1578+
return compositionTy->getExistentialLayout().superclass;
1579+
15771580
// No other types have superclasses.
1578-
return nullptr;
1581+
return Type();
15791582
}
15801583

15811584
// We have a class, so get the superclass type.

0 commit comments

Comments
 (0)