Sema: Enable covariant erasure for dependent member types

This commit is contained in:
Anthony Latsis
2021-10-01 07:00:34 +03:00
parent c47f99a22d
commit 24c19d4ad4
6 changed files with 151 additions and 65 deletions

View File

@@ -5991,11 +5991,12 @@ bool ConstraintSystem::isMemberAvailableOnExistential(
Type baseTy, const ValueDecl *member) const {
assert(member->getDeclContext()->getSelfProtocolDecl());
// If the type of the member references 'Self' in non-covariant position, or
// an associated type in any position, we cannot make use of the member.
// If the type of the member references 'Self' or a 'Self'-rooted associated
// type in non-covariant position, we cannot reference the member.
const auto info = member->findExistentialSelfReferences(
baseTy, /*treatNonResultCovariantSelfAsInvariant=*/false);
if (info.selfRef > TypePosition::Covariant || info.assocTypeRef) {
if (info.selfRef > TypePosition::Covariant ||
info.assocTypeRef > TypePosition::Covariant) {
return false;
}