[6.2] Add lifetime dependencies on function types representing ~Escapable enum elements with ~Escapable payloads #82431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: Enum elements are represented as a function type. Enums can satisfy a protocol's static method constraint by defining a enum element with the same signature.
We do not infer lifetime dependence on function types related to EnumElementDecl. This results to source compatibility bugs in some cases since Optional is now conditionally ~Escapable. In the example below a protocol specifying a static some method ends up with a generated witness that does not have lifetime dependencies leading to illegible diagnostics.
This PR adds lifetime dependencies for function types representative of EnumElementDecls.
Scope: Affects ~Escapable and conditionally ~Escapable types
Risk: Medium. New code is exercised in the type checker on all conditionally ~Escapable enums.
Main PR: #82354
Reviewer: @atrick
Testing: CI testing.
Issue: rdar://152104558