[6.2][concurrency] Ensure that we treat closures that are nonisolated(nonsending) via their ActorIsolation as nonisolated(nonsending). #81363
+420
β79
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: This PR fixes a bug where we were not assigning to SILFunctions from closures the actor isolation (and thus whether or not they have an implicit isolated parameter) from AbstractClosureExpr::actorIsolation. The result of this was that we would produce SILFunctionTypes that were inconsistent with the AnyFunctionType that they were lowered since AnyFunctionType's with nonisolated(nonsending) isolation would get SILFunctions without an implicit isolated parameter. This would then cause us to invoke SILGenPoly's transform infrastructure to crash.
In the process, @xedin and I also discovered that in the specific case we were looking at where one had two levels of auto closures, we were not visiting the inner auto closure in the ActorIsolationChecker meaning that we did not set AbstractClosureExpr::actorIsolation upon it. Since ensuring that we visited these auto closures in the ActorIsolationChecker would increase the surface area of the language that we were checking and result in potential source stable changes, we took a more targeted approach by recognizing the specific case where this happens in the type checker and just setting the appropriate actor isolation there.
Scope: Ensures that the inner auto closures in the test case in question have the appropriate actor isolation and that SILFunctions in general that are from closures respect the closure's actorIsolation if it is set.
Resolves: rdar://150209093
Main PR: #81338
Risk: Low. There are two things to consider: 1. By making it so that SILFunction/SILFunctionType respects the actor isolation of closures could change ABI in the case of nonisolated(nonsending) being lowered correctly. 2. Separately by ensuring in this specific inner/outer auto closure case that the inner auto closure has its actor isolation set correctly in the type checker instead of visiting in the ActorIsolationChecker, we keep the amount of risk caused by this change way done and avoid potentially source stability issues.
Testing: Added compiler tests
Reviewer: @xedin