@@ -7438,7 +7438,7 @@ void ConstraintSystem::maybeProduceFallbackDiagnostic(
74387438// / Because opened archetypes are not part of the surface language, these
74397439// / constraints render the member inaccessible.
74407440static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase (
7441- Type baseTy , const ValueDecl *member) {
7441+ OpenedExistentialSignature existentialSig , const ValueDecl *member) {
74427442 const auto sig =
74437443 member->getInnermostDeclContext ()->getGenericSignatureOfContext ();
74447444
@@ -7447,9 +7447,6 @@ static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase(
74477447 return false ;
74487448 }
74497449
7450- auto &ctx = member->getASTContext ();
7451- auto existentialSig = ctx.getOpenedExistentialSignature (baseTy);
7452-
74537450 class IsDependentOnOpenedExistentialSelf : public TypeWalker {
74547451 OpenedExistentialSignature existentialSig;
74557452
@@ -7542,20 +7539,14 @@ bool ConstraintSystem::isMemberAvailableOnExistential(
75427539 Type baseTy, const ValueDecl *member) const {
75437540 assert (member->getDeclContext ()->getSelfProtocolDecl ());
75447541
7545- // If the type of the member references 'Self' or a 'Self'-rooted associated
7546- // type in non-covariant position, we cannot reference the member.
7547- assert (baseTy->isExistentialType ());
7548- assert (!baseTy->hasTypeParameter ());
7542+ auto existentialSig = getASTContext ().getOpenedExistentialSignature (baseTy);
75497543
7550- // Note: a non-null GenericSignature would violate the invariant that
7551- // the protocol 'Self' type referenced from the requirement's interface
7552- // type is the same as the existential 'Self' type.
7553- auto sig = getASTContext ().getOpenedExistentialSignature (baseTy,
7554- GenericSignature ());
7544+ auto *dc = member->getDeclContext ();
7545+ auto origParam = dc->getSelfInterfaceType ()->castTo <GenericTypeParamType>();
7546+ auto openedParam = existentialSig.SelfType ->castTo <GenericTypeParamType>();
75557547
7556- auto genericParam = sig.getGenericParams ().front ();
75577548 auto info = findGenericParameterReferences (
7558- member, sig, genericParam, genericParam ,
7549+ member, existentialSig. OpenedSig , origParam, openedParam ,
75597550 std::nullopt );
75607551
75617552 if (info.selfRef > TypePosition::Covariant ||
@@ -7569,7 +7560,7 @@ bool ConstraintSystem::isMemberAvailableOnExistential(
75697560 return false ;
75707561 }
75717562
7572- if (doesMemberHaveUnfulfillableConstraintsWithExistentialBase (baseTy ,
7563+ if (doesMemberHaveUnfulfillableConstraintsWithExistentialBase (existentialSig ,
75737564 member)) {
75747565 return false ;
75757566 }
0 commit comments