mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Account for ExistentialType in lookupExistentialConformance.
This commit is contained in:
@@ -978,13 +978,17 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
|
||||
// existential to an archetype parameter, so for now we restrict this to
|
||||
// @objc protocols and marker protocols.
|
||||
if (!layout.isObjC() && !protocol->isMarkerProtocol()) {
|
||||
auto constraint = type;
|
||||
if (auto existential = constraint->getAs<ExistentialType>())
|
||||
constraint = existential->getConstraintType();
|
||||
|
||||
// There's a specific exception for protocols with self-conforming
|
||||
// witness tables, but the existential has to be *exactly* that type.
|
||||
// TODO: synthesize witness tables on-demand for protocol compositions
|
||||
// that can satisfy the requirement.
|
||||
if (protocol->requiresSelfConformanceWitnessTable() &&
|
||||
type->is<ProtocolType>() &&
|
||||
type->castTo<ProtocolType>()->getDecl() == protocol)
|
||||
constraint->is<ProtocolType>() &&
|
||||
constraint->castTo<ProtocolType>()->getDecl() == protocol)
|
||||
return ProtocolConformanceRef(ctx.getSelfConformance(protocol));
|
||||
|
||||
return ProtocolConformanceRef::forInvalid();
|
||||
|
||||
Reference in New Issue
Block a user