Skip to content

Commit 1d56338

Browse files
committed
[SILOptimizer] Use the constraint type in ExistentialSpecializer when
finding the protocol decl for an existential type.
1 parent 86730ca commit 1d56338

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialSpecializer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ bool ExistentialSpecializer::findConcreteTypeFromSoleConformingType(
9595
auto ArgType = Arg->getType();
9696
auto SwiftArgType = ArgType.getASTType();
9797

98+
CanType constraint = SwiftArgType;
99+
if (auto existential = constraint->getAs<ExistentialType>())
100+
constraint = existential->getConstraintType()->getCanonicalType();
101+
98102
/// Do not handle composition types yet.
99-
if (isa<ProtocolCompositionType>(SwiftArgType))
103+
if (isa<ProtocolCompositionType>(constraint))
100104
return false;
101105
assert(ArgType.isExistentialType());
102106
/// Find the protocol decl.
103-
auto *PD = dyn_cast<ProtocolDecl>(SwiftArgType->getAnyNominal());
107+
auto *PD = dyn_cast<ProtocolDecl>(constraint->getAnyNominal());
104108
if (!PD)
105109
return false;
106110

0 commit comments

Comments
 (0)