Skip to content

Implement -strict-concurrency control and default to "minimal" #42523

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

Merged

Conversation

DougGregor
Copy link
Member

Replace -warn-concurrency with a more granular option
-swift-concurrency=, where the developer can select one of three
different "modes":

  • minimal disables Sendable checking for most cases. (This is the Swift
    5.5 and Swift 5.6 behavior, and the default for now)
  • targeted enables Sendable checking within code that has adopted
    Swift concurrency.
  • complete enables Sendable and other concurrency checking throughout
    the module. (This is equivalent to -warn-concurrency now).

Implements rdar://91930849.

Replace `-warn-concurrency` with a more granular option
`-swift-concurrency=`, where the developer can select one of three
different "modes":

* `off` disables `Sendable` checking for most cases. (This is the Swift
5.5 and Swift 5.6 behavior.)
* `limited` enables `Sendable` checking within code that has adopted
Swift concurrency. (This is currently the default behavior.)
* `on` enables `Sendable` and other concurrency checking throughout
the module. (This is equivalent to `-warn-concurrency` now).

There is currently no distinction between `off` and `limited`. That
will come soon.

Implements the flag part of rdar://91930849.

(cherry picked from commit 7a724c4)
`isConcurrencyChecked()` was being used as a proxy for
`-warn-concurrency` that didn't account for Swift 6. Replace
checks against it within the current module with checks against the
strict concurrency level, which subsumes the Swift 6 check and can
account for the difference between "limited" and "on".

`isConcurrencyChecked()` is used now used exclusively to mean "treat a
missing Sendable conformance as an explicitly-non-Sendable type".

(cherry picked from commit d200644)
(cherry picked from commit 4306c9c)
This isolates us from changes in the default.

(cherry picked from commit f404b58)
The three options are now:

* `explicit`: Enforce Sendable constraints where it has been explicitly adopted and perform actor-isolation checking wherever code has adopted concurrency. (This is the default)
* `targeted`: Enforce Sendable constraints and perform actor-isolation checking wherever code has adopted concurrency, including code that has explicitly adopted Sendable.
* `complete`: Enforce Sendable constraints and actor-isolation checking throughout the entire module.

(cherry picked from commit 4116d7a)
This makes it far more clear what the relative ordering of the options is.

Thanks, Jake!
Emulate the behavior of Swift 5.5/5.6 by default, using
`-strict-concurrency=minimal`.
@DougGregor DougGregor requested a review from a team as a code owner April 21, 2022 04:49
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I wonder if some of the longer descriptions from the enum about minimal could benefit being in the command line. Not really important tho as in reality folks can "try out and see which one does what they want" :)

@DougGregor DougGregor merged commit efbd7cd into swiftlang:release/5.7 Apr 21, 2022
@DougGregor DougGregor deleted the strict-concurrency-minimal-5.7 branch April 21, 2022 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants