@@ -6,6 +6,60 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66Swift 5.6
77---------
88
9+ * [ SE-0337] [ ] :
10+
11+ Swift now provides an incremental migration path to data race safety, allowing
12+ APIs to adopt concurrency without breaking their clients that themselves have
13+ not adopted concurrency. An existing declaration can introduce
14+ concurrency-related annotations (such as making its closure parameters
15+ ` @Sendable ` ) and use the ` @preconcurrency ` attribute to maintain its behavior
16+ for clients who have not themselves adopted concurrency:
17+
18+ ``` swift
19+ // module A
20+ @preconcurrency func runOnSeparateTask (_ workItem : @Sendable () -> Void )
21+
22+ // module B
23+ import A
24+
25+ class MyCounter {
26+ var value = 0
27+ }
28+
29+ func doesNotUseConcurrency (counter : MyCounter) {
30+ runOnSeparateTask {
31+ counter.value += 1 // no warning, because this code hasn't adopted concurrency
32+ }
33+ }
34+
35+ func usesConcurrency (counter : MyCounter) async {
36+ runOnSeparateTask {
37+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
38+ }
39+ }
40+ ```
41+
42+ One can enable warnings about data race safety within a module with the
43+ ` -warn-concurrency ` compiler option. When using a module that does not yet
44+ provide ` Sendable ` annotations, one can suppress warnings for types from that
45+ module by marking the import with ` @preconcurrency ` :
46+
47+ ``` swift
48+ /// module C
49+ public struct Point {
50+ public var x, y: Double
51+ }
52+
53+ // module D
54+ @preconcurrency import C
55+
56+ func centerView (at location : Point) {
57+ Task {
58+ await mainView.center (at : location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
59+ }
60+ }
61+ ```
62+
963* [ SE-0302] [ ] :
1064
1165 Swift will now produce warnings to indicate potential data races when
@@ -8782,6 +8836,7 @@ Swift 1.0
87828836[SE- 0316 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
87838837[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87848838[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
8839+ [SE- 0337 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
87858840
87868841[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
87878842[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments