[Concurrency] Don't allow erasing global actor isolation when the function value crosses an isolation boundary. #72607
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.
The actor isolation checker allows erasing global actor isolation in function conversions when the conversion happens in the same isolation domain and the destination type is not Sendable under the assumption that the function value will never cross an isolation boundary. This is an important rule, because it allows calling synchronous higher order function APIs with global actor isolated function values as long as you're calling from a global actor isolated context. However, the actor isolation checker was allowing the conversion in cases where the function value crosses an isolation boundary:
This PR diagnoses the function conversion that loses actor isolation if the function conversion is an argument to a call that crosses an isolation boundary.
We still need to fix this case under region isolation:
Currently, the above code is "fine" because the function conversion itself isn't crossing an isolation boundary, and from the perspective of region analysis,
erased
is in a disconnected region. I think the way to solve this is to mergeerased
to the main actor region due to the function conversion that erases main actor isolation.Resolves: rdar://118206647