Sema: Narrow down the skipProtocolSelfConstraint hack

We actually have to check this constraint, otherwise we accept invalid
code where we're referencing a protocol requirement with a concrete
base type which conditionally conforms to the protocol, but the
conditional requirements are unsatisfied.

However, we still need to skip it for AnyObject lookup, Distributed
Actors, and some weird edge case in conformance checking for isolated
conformances.

We should clean this up further later, but for now this closes a soundness
hole.

Fixes rdar://168129757.
This commit is contained in:
Slava Pestov
2026-01-14 11:59:36 -05:00
parent 6f81699db2
commit ee0f6dd681
6 changed files with 60 additions and 27 deletions

View File

@@ -3472,7 +3472,7 @@ void OpenGenericTypeRequirements::operator()(GenericTypeDecl *decl,
auto openType = [&](Type ty) -> Type {
return cs.openType(ty, replacements, locator, preparedOverload);
};
cs.openGenericRequirements(outerDC, sig, /*skipProtocolSelf*/ false, locator,
cs.openGenericRequirements(outerDC, sig, /*skipProtocolSelfConstraint=*/false, locator,
openType, preparedOverload);
}