[CSSolver] Handle situations when key path expression has an existential type

A way to mark key path as Sendable is to extend its type with `& Sendable`.
This is something that makes the type of a key path expression an existential
with superclass bound expressed as a known key path type.
This commit is contained in:
Pavel Yaskevich
2023-11-28 11:05:51 -08:00
parent 316e8f9366
commit d72749560f
2 changed files with 12 additions and 0 deletions

View File

@@ -12195,6 +12195,12 @@ ConstraintSystem::simplifyKeyPathConstraint(
if (contextualTy->isPlaceholder())
return true;
// Situations like `any KeyPath<...> & Sendable`.
if (contextualTy->isExistentialType()) {
contextualTy = contextualTy->getExistentialLayout().explicitSuperclass;
assert(contextualTy);
}
// If there are no other options the solver might end up picking
// `AnyKeyPath` or `PartialKeyPath` based on a contextual conversion.
// This is an error during normal type-checking but okay in