@@ -19,6 +19,86 @@ _**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+
76+ * [ SE-0302] [ ] :
77+
78+ Swift will now produce warnings to indicate potential data races when
79+ non-` Sendable ` types are passed across actor or task boundaries. For
80+ example:
81+
82+ ``` swift
83+ class MyCounter {
84+ var value = 0
85+ }
86+
87+ func f () -> MyCounter {
88+ let counter = MyCounter ()
89+ Task {
90+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
91+ }
92+ return counter
93+ }
94+ ```
95+
96+ * [ SE-0331] [ ] :
97+
98+ The conformance of the unsafe pointer types (e.g., ` UnsafePointer ` ,
99+ ` UnsafeMutableBufferPointer ` ) to the ` Sendable ` protocols has been removed,
100+ because pointers cannot safely be transferred across task or actor boundaries.
101+
22102* References to ` Self ` or so-called "` Self ` requirements" in the type signatures
23103 of protocol members are now correctly detected in the parent of a nested type.
24104 As a result, protocol members that fall under this overlooked case are no longer
@@ -39,7 +119,7 @@ Swift 5.6
39119 // protocol type (use a generic constraint instead).
40120 _ = p.method
41121 }
42- ```
122+ ```
43123
44124* [ SE-0324] [ ] :
45125
@@ -66,6 +146,19 @@ Swift 5.6
66146 }
67147 ```
68148
149+ * [ SE-0322] [ ] :
150+
151+ The standard library now provides a new operation
152+ ` withUnsafeTemporaryAllocation ` which provides an efficient temporarily
153+ allocation within a limited scope, which will be optimized to use stack
154+ allocation when possible.
155+
156+ * [ SE-0320] [ ] :
157+
158+ Dictionaries with keys of any type conforming to the new protocol
159+ ` CodingKeyRepresentable ` can now be encoded and decoded. Formerly, encoding
160+ and decoding was limited to keys of type ` String ` or ` Int ` .
161+
69162* [ SE-0315] [ ] :
70163
71164 Type expressions and annotations can now include "type placeholders" which
@@ -8766,15 +8859,20 @@ Swift 1.0
87668859[SE- 0298 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
87678860[SE- 0299 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
87688861[SE- 0300 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
8862+ [SE- 0302 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md>
87698863[SE- 0306 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
87708864[SE- 0310 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
87718865[SE- 0311 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
87728866[SE- 0313 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
87738867[SE- 0315 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
87748868[SE- 0316 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8869+ [SE- 0320 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0320-codingkeyrepresentable.md>
8870+ [SE- 0322 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
87758871[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87768872[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
87778873[SE- 0328 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
8874+ [SE- 0331 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
8875+ [SE- 0337 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
87788876
87798877[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
87808878[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments