@@ -5000,24 +5000,26 @@ CanGenericSignature ASTContext::getSingleGenericParameterSignature() const {
5000
5000
// constraints while existential values do.
5001
5001
CanGenericSignature ASTContext::getOpenedArchetypeSignature (Type type) {
5002
5002
assert (type->isExistentialType ());
5003
+ if (auto existential = type->getAs <ExistentialType>())
5004
+ type = existential->getConstraintType ();
5003
5005
5004
- const CanType existential = type->getCanonicalType ();
5006
+ const CanType constraint = type->getCanonicalType ();
5005
5007
5006
5008
// The opened archetype signature for a protocol type is identical
5007
5009
// to the protocol's own canonical generic signature.
5008
- if (const auto protoTy = dyn_cast<ProtocolType>(existential )) {
5010
+ if (const auto protoTy = dyn_cast<ProtocolType>(constraint )) {
5009
5011
return protoTy->getDecl ()->getGenericSignature ().getCanonicalSignature ();
5010
5012
}
5011
5013
5012
- auto found = getImpl ().ExistentialSignatures .find (existential );
5014
+ auto found = getImpl ().ExistentialSignatures .find (constraint );
5013
5015
if (found != getImpl ().ExistentialSignatures .end ())
5014
5016
return found->second ;
5015
5017
5016
5018
auto genericParam =
5017
5019
GenericTypeParamType::get (/* type sequence*/ false ,
5018
5020
/* depth*/ 0 , /* index*/ 0 , *this );
5019
5021
Requirement requirement (RequirementKind::Conformance, genericParam,
5020
- existential );
5022
+ constraint );
5021
5023
auto genericSig = buildGenericSignature (*this ,
5022
5024
GenericSignature (),
5023
5025
{genericParam},
@@ -5026,7 +5028,7 @@ CanGenericSignature ASTContext::getOpenedArchetypeSignature(Type type) {
5026
5028
CanGenericSignature canGenericSig (genericSig);
5027
5029
5028
5030
auto result = getImpl ().ExistentialSignatures .insert (
5029
- std::make_pair (existential , canGenericSig));
5031
+ std::make_pair (constraint , canGenericSig));
5030
5032
assert (result.second );
5031
5033
(void ) result;
5032
5034
0 commit comments