@@ -19,6 +19,86 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
19
19
Swift 5.6
20
20
---------
21
21
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
+
22
102
* References to ` Self ` or so-called "` Self ` requirements" in the type signatures
23
103
of protocol members are now correctly detected in the parent of a nested type.
24
104
As a result, protocol members that fall under this overlooked case are no longer
@@ -39,7 +119,7 @@ Swift 5.6
39
119
// protocol type (use a generic constraint instead).
40
120
_ = p.method
41
121
}
42
- ```
122
+ ```
43
123
44
124
* [ SE-0324] [ ] :
45
125
@@ -66,6 +146,19 @@ Swift 5.6
66
146
}
67
147
```
68
148
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
+
69
162
* [ SE-0315] [ ] :
70
163
71
164
Type expressions and annotations can now include "type placeholders" which
@@ -8766,15 +8859,20 @@ Swift 1.0
8766
8859
[SE- 0298 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
8767
8860
[SE- 0299 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
8768
8861
[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>
8769
8863
[SE- 0306 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
8770
8864
[SE- 0310 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
8771
8865
[SE- 0311 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
8772
8866
[SE- 0313 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
8773
8867
[SE- 0315 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
8774
8868
[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>
8775
8871
[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
8776
8872
[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
8777
8873
[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>
8778
8876
8779
8877
[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
8780
8878
[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments