@@ -19,6 +19,60 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
1919Swift 5.6
2020---------
2121
22+ * [ SE-0337] [ ] :
23+
24+ Swift now provides an incremental migration path to data race safety, allowing
25+ APIs to adopt concurrency without breaking their clients that themselves have
26+ not adopted concurrency. An existing declaration can introduce
27+ concurrency-related annotations (such as making its closure parameters
28+ ` @Sendable ` ) and use the ` @preconcurrency ` attribute to maintain its behavior
29+ for clients who have not themselves adopted concurrency:
30+
31+ ``` swift
32+ // module A
33+ @preconcurrency func runOnSeparateTask (_ workItem : @Sendable () -> Void )
34+
35+ // module B
36+ import A
37+
38+ class MyCounter {
39+ var value = 0
40+ }
41+
42+ func doesNotUseConcurrency (counter : MyCounter) {
43+ runOnSeparateTask {
44+ counter.value += 1 // no warning, because this code hasn't adopted concurrency
45+ }
46+ }
47+
48+ func usesConcurrency (counter : MyCounter) async {
49+ runOnSeparateTask {
50+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
51+ }
52+ }
53+ ```
54+
55+ One can enable warnings about data race safety within a module with the
56+ ` -warn-concurrency ` compiler option. When using a module that does not yet
57+ provide ` Sendable ` annotations, one can suppress warnings for types from that
58+ module by marking the import with ` @preconcurrency ` :
59+
60+ ``` swift
61+ /// module C
62+ public struct Point {
63+ public var x, y: Double
64+ }
65+
66+ // module D
67+ @preconcurrency import C
68+
69+ func centerView (at location : Point) {
70+ Task {
71+ await mainView.center (at : location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
72+ }
73+ }
74+ ```
75+
2276* [ SE-0302] [ ] :
2377
2478 Swift will now produce warnings to indicate potential data races when
@@ -8796,6 +8850,7 @@ Swift 1.0
87968850[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87978851[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
87988852[SE- 0328 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
8853+ [SE- 0337 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
87998854
88008855[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
88018856[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments