Isolation fixes for closures and defer bodies #84181
Merged
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.
I was trying to just fix a bug where
#isolation
wasn't evaluated properly in closure expressions, but I realized that my fix had the potential to affect other cases, and my investigations revealed three other bugs:defer
scopes, so nesteddefer
bodies were being treated as non-isolated.defer
body did not look upwards at all, sodefer
bodies were not treated as being isolated the same way as their parent function. I think we might have compensated for this in a lot of ways, but#isolation
could not possibly have evaluated correctly in caller-isolated contexts because thedefer
body simply didn't get the isolation passed to it.nonisolated(nonsending)
functions was never returning caller-isolated, so these functions were not receiving implicit isolation parameters or using them correctly.I ended up going around in circles on the default-arguments bug a lot, and eventually I settled on implementing most of the structure necessary for fixing it but not actually fixing it. Changing the computation of the isolation should now just make everything in SILGen work.
The other bugs with closures and
defer
should all be fixed.