@@ -7438,7 +7438,7 @@ void ConstraintSystem::maybeProduceFallbackDiagnostic(
7438
7438
// / Because opened archetypes are not part of the surface language, these
7439
7439
// / constraints render the member inaccessible.
7440
7440
static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase (
7441
- Type baseTy , const ValueDecl *member) {
7441
+ OpenedExistentialSignature existentialSig , const ValueDecl *member) {
7442
7442
const auto sig =
7443
7443
member->getInnermostDeclContext ()->getGenericSignatureOfContext ();
7444
7444
@@ -7447,9 +7447,6 @@ static bool doesMemberHaveUnfulfillableConstraintsWithExistentialBase(
7447
7447
return false ;
7448
7448
}
7449
7449
7450
- auto &ctx = member->getASTContext ();
7451
- auto existentialSig = ctx.getOpenedExistentialSignature (baseTy);
7452
-
7453
7450
class IsDependentOnOpenedExistentialSelf : public TypeWalker {
7454
7451
OpenedExistentialSignature existentialSig;
7455
7452
@@ -7542,20 +7539,14 @@ bool ConstraintSystem::isMemberAvailableOnExistential(
7542
7539
Type baseTy, const ValueDecl *member) const {
7543
7540
assert (member->getDeclContext ()->getSelfProtocolDecl ());
7544
7541
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);
7549
7543
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>();
7555
7547
7556
- auto genericParam = sig.getGenericParams ().front ();
7557
7548
auto info = findGenericParameterReferences (
7558
- member, sig, genericParam, genericParam ,
7549
+ member, existentialSig. OpenedSig , origParam, openedParam ,
7559
7550
std::nullopt);
7560
7551
7561
7552
if (info.selfRef > TypePosition::Covariant ||
@@ -7569,7 +7560,7 @@ bool ConstraintSystem::isMemberAvailableOnExistential(
7569
7560
return false ;
7570
7561
}
7571
7562
7572
- if (doesMemberHaveUnfulfillableConstraintsWithExistentialBase (baseTy ,
7563
+ if (doesMemberHaveUnfulfillableConstraintsWithExistentialBase (existentialSig ,
7573
7564
member)) {
7574
7565
return false ;
7575
7566
}
0 commit comments