-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] explicit nonisolated specification for closures #72175
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
[Concurrency] explicit nonisolated specification for closures #72175
Conversation
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.
This reminded me about the let nonisolated = ""; Task { nonisolated in }
case, did we figure out how to deal with those, like that I guess or we ignore that weird case?
Task {`nonisolated` in }
I believe that is not an issue. Your example already is valid code and, without this change, would declare an inferred-type parameter to the closure |
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 don’t think this approach works.
For example the following is currently valid Swift code:
let closure = { open in
print(open)
}
closure("abc")
But with this change I assume that open
would get parsed as a decl modifier and it would stop working. It would definitely be good to add a test case for something like this.
Also, this needs implementation in the new parser as well
Ah good point. My current implementation will at least fail later any modifier other than
Yes sorry, I meant to comment that I am working on that, but due to the nature of the change, the lack of it does not block CI here so I wanted to open this for review earlier rather than wait. |
FWIW I think that even the source break for |
No one on the pitch as of yet has expressed concern about this, so you may want to if it worries you: https://forums.swift.org/t/closure-isolation-control/70378 |
80d83cd
to
e564145
Compare
63170ad
to
94969ed
Compare
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.
Does this flag need to be serialized into AbstractClosureExprLayout
as well?
@@ -1,4 +1,4 @@ | |||
// RUN: %target-swift-frontend -dump-ast %s -disable-availability-checking | %FileCheck %s | |||
// RUN: %target-swift-frontend -dump-ast %s -disable-availability-checking -enable-experimental-feature ClosureIsolation | %FileCheck %s |
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.
Since you added -enable-experimental-feature
this test-case now needs // REQUIRES: asserts
I do not believe so. Technically speaking, no flag or new state has been added. Closures already have had formal isolation, just not the ability to explicitly specify the option of |
@sophiapoirier What I meant by "flag" is whether |
Ah I see. I would still go back though to what I said about currently |
Due to bike shedding on syntax, I am holding off on swift-syntax implementation pending language evolution review decisions on a final syntax direction. Currently I have omitted one test that would fail due to different results from swift-syntax, but I will introduce it along with a final syntax implementation. |
57d7ce0
to
d683dd8
Compare
squashing resets CI results??? RUDE. |
f60508a
to
5ce7be7
Compare
@swift-ci please test |
https://github.com/sophiapoirier/swift-evolution/blob/closure-isolation/proposals/nnnn-closure-isolation-control.md