-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[6.2][sil-isolation-info] When determining isolation of a function arg, use its VarDecl. #80953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.2][sil-isolation-info] When determining isolation of a function arg, use its VarDecl. #80953
Conversation
…e its VarDecl. Otherwise, we can be inconsistent with isolations returned by other parts of the code. Previously we were just treating it always as self + nom decl, which is clearly wrong if a type is not self (e.x.: if it is an isolated parameter). rdar://135459885 (cherry picked from commit 0ece31e)
@swift-ci test |
@@ -13,9 +13,6 @@ actor Test { | |||
func withTaskLocal(isolation: isolated (any Actor)? = #isolation, | |||
_ body: (consuming NonSendableValue, isolated (any Actor)?) -> Void) async { | |||
Self.$local.withValue(12) { | |||
// Unexpected errors here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: We already did not emit this error. But this PR exercised the code in this area and when I was working on it the error came back, so I looked at it. The comment here is from when we still emitted the error here (and I put in my previous fix), so I removed it to prevent any confusion.
if (getKind() != Kind::Actor) | ||
return false; | ||
return getActorIsolation() == actorIsolation; | ||
return getActorIsolation() == other; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this renaming since SILIsolationInfo has a field called actorIsolation. It can get confusing what one is referring to int he debugger.
@swift-ci test macOS platform |
@swift-ci test macOS platform |
@swift-ci clean test macOS platform |
Explanation: What this patch does is it changes the way that we determine the SILIsolationInfo that we derive from function arguments that are isolated parameters. Previously, we would incorrectly just use self + nom decl to create a SILIsolationInfo... which is obviously wrong. Now instead, we use the correct formulation which is to construct the isolation info frmo the VarDecl of the SILFunctionArgument. This ensures that in cases like the following we correctly realize that the closure's isolation (which is the VarDecl) is the same as self whose isolation is derived from the isolated parameter's VarDecl preventing an error from being emitted:
Scope: Changes how we compute SILIsolationInfo from SILFunctionArguments that are isolated parameters.
Resolves: rdar://135459885
Main PR: #80905
Risk: Low. This just tweaks how we compute isolation. It shouldn't affect anything beyond situations that use isolated parameters.
Testing: Added tests that show that we emit the correct diagnostic and added a SIL level test that directly shows that we infer the isolation correctly.
Reviewer: @ktoso