Sema: Implement missing case in existential erasure

Fixes https://github.com/apple/swift/issues/61934.
This commit is contained in:
Slava Pestov
2023-12-14 17:49:34 -05:00
parent 2b2beb6ced
commit 2b28cb1647
2 changed files with 42 additions and 0 deletions

View File

@@ -2284,6 +2284,20 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
}
}
// Parameterized protocol types whose arguments involve this type
// parameter are erased to the base type.
if (auto parameterized = dyn_cast<ParameterizedProtocolType>(t)) {
for (auto argType : parameterized->getArgs()) {
auto erasedArgType =
typeEraseExistentialSelfReferences(
argType, baseTy, TypePosition::Covariant,
existentialSig, containsFn, predicateFn, projectionFn,
force, metatypeDepth);
if (erasedArgType.getPointer() != argType.getPointer())
return parameterized->getBaseType();
}
}
if (auto lvalue = dyn_cast<LValueType>(t)) {
auto objTy = lvalue->getObjectType();
auto erasedTy =