Merge pull request #84501 from slavapestov/fix-rdar160389221

Sema: Workaround for broken existential opening behavior
This commit is contained in:
Slava Pestov
2025-09-26 18:36:49 -04:00
committed by GitHub
2 changed files with 35 additions and 1 deletions

View File

@@ -13394,8 +13394,12 @@ retry_after_fail:
choiceType = objectType;
}
// FIXME: The !getSelfProtocolDecl() check is load-bearing, because
// this optimization interacts poorly with existential opening
// somehow. It should all be removed.
if (auto *choiceFnType = choiceType->getAs<FunctionType>()) {
if (isa<ConstructorDecl>(choice.getDecl())) {
if (isa<ConstructorDecl>(choice.getDecl()) &&
!choice.getDecl()->getDeclContext()->getSelfProtocolDecl()) {
auto choiceResultType = choice.getBaseType()
->getRValueType()
->getMetatypeInstanceType();