Skip to content

Commit f368b77

Browse files
committed
[Sema] Account for ExistentialType in lookupExistentialConformance.
1 parent cf44889 commit f368b77

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/AST/Module.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,13 +978,17 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
978978
// existential to an archetype parameter, so for now we restrict this to
979979
// @objc protocols and marker protocols.
980980
if (!layout.isObjC() && !protocol->isMarkerProtocol()) {
981+
auto constraint = type;
982+
if (auto existential = constraint->getAs<ExistentialType>())
983+
constraint = existential->getConstraintType();
984+
981985
// There's a specific exception for protocols with self-conforming
982986
// witness tables, but the existential has to be *exactly* that type.
983987
// TODO: synthesize witness tables on-demand for protocol compositions
984988
// that can satisfy the requirement.
985989
if (protocol->requiresSelfConformanceWitnessTable() &&
986-
type->is<ProtocolType>() &&
987-
type->castTo<ProtocolType>()->getDecl() == protocol)
990+
constraint->is<ProtocolType>() &&
991+
constraint->castTo<ProtocolType>()->getDecl() == protocol)
988992
return ProtocolConformanceRef(ctx.getSelfConformance(protocol));
989993

990994
return ProtocolConformanceRef::forInvalid();

0 commit comments

Comments
 (0)