@@ -6,6 +6,104 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
6
6
Swift 5.6
7
7
---------
8
8
9
+ * [ SE-0335] [ ] :
10
+
11
+ Swift now allows existential types to be explicitly written with the ` any `
12
+ keyword, creating a syntactic distinction between existential types and
13
+ protocol conformance constraints. For example:
14
+
15
+ ``` swift
16
+ protocol P {}
17
+
18
+ func generic <T >(value : T) where T: P {
19
+ ...
20
+ }
21
+
22
+ func existential (value : any P) {
23
+ ...
24
+ }
25
+ ```
26
+
27
+ * [ SE-0337] [ ] :
28
+
29
+ Swift now provides an incremental migration path to data race safety, allowing
30
+ APIs to adopt concurrency without breaking their clients that themselves have
31
+ not adopted concurrency. An existing declaration can introduce
32
+ concurrency-related annotations (such as making its closure parameters
33
+ ` @Sendable ` ) and use the ` @preconcurrency ` attribute to maintain its behavior
34
+ for clients who have not themselves adopted concurrency:
35
+
36
+ ``` swift
37
+ // module A
38
+ @preconcurrency func runOnSeparateTask (_ workItem : @Sendable () -> Void )
39
+
40
+ // module B
41
+ import A
42
+
43
+ class MyCounter {
44
+ var value = 0
45
+ }
46
+
47
+ func doesNotUseConcurrency (counter : MyCounter) {
48
+ runOnSeparateTask {
49
+ counter.value += 1 // no warning, because this code hasn't adopted concurrency
50
+ }
51
+ }
52
+
53
+ func usesConcurrency (counter : MyCounter) async {
54
+ runOnSeparateTask {
55
+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
56
+ }
57
+ }
58
+ ```
59
+
60
+ One can enable warnings about data race safety within a module with the
61
+ ` -warn-concurrency ` compiler option. When using a module that does not yet
62
+ provide ` Sendable ` annotations, one can suppress warnings for types from that
63
+ module by marking the import with ` @preconcurrency ` :
64
+
65
+ ``` swift
66
+ /// module C
67
+ public struct Point {
68
+ public var x, y: Double
69
+ }
70
+
71
+ // module D
72
+ @preconcurrency import C
73
+
74
+ func centerView (at location : Point) {
75
+ Task {
76
+ await mainView.center (at : location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
77
+ }
78
+ }
79
+ ```
80
+
81
+ * [ SE-0302] [ ] :
82
+
83
+ Swift will now produce warnings to indicate potential data races when
84
+ non-` Sendable ` types are passed across actor or task boundaries. For
85
+ example:
86
+
87
+ ``` swift
88
+ class MyCounter {
89
+ var value = 0
90
+ }
91
+
92
+ func f () -> MyCounter {
93
+ let counter = MyCounter ()
94
+ Task {
95
+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
96
+ }
97
+ return counter
98
+ }
99
+ ```
100
+
101
+ * [ SE-0331] [ ] :
102
+
103
+ The conformance of the unsafe pointer types (e.g., ` UnsafePointer ` ,
104
+ ` UnsafeMutableBufferPointer ` ) to the ` Sendable ` protocols has been removed,
105
+ because pointers cannot safely be transferred across task or actor boundaries.
106
+
9
107
* References to ` Self ` or so-called "` Self ` requirements" in the type signatures
10
108
of protocol members are now correctly detected in the parent of a nested type.
11
109
As a result, protocol members that fall under this overlooked case are no longer
@@ -26,7 +124,7 @@ Swift 5.6
26
124
// protocol type (use a generic constraint instead).
27
125
_ = p.method
28
126
}
29
- ```
127
+ ```
30
128
31
129
* [ SE-0324] [ ] :
32
130
@@ -53,6 +151,13 @@ Swift 5.6
53
151
}
54
152
```
55
153
154
+ * [ SE-0322] [ ] :
155
+
156
+ The standard library now provides a new operation
157
+ ` withUnsafeTemporaryAllocation ` which provides an efficient temporarily
158
+ allocation within a limited scope, which will be optimized to use stack
159
+ allocation when possible.
160
+
56
161
* [ SE-0315] [ ] :
57
162
58
163
Type expressions and annotations can now include "type placeholders" which
@@ -8753,14 +8858,19 @@ Swift 1.0
8753
8858
[SE- 0298 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
8754
8859
[SE- 0299 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
8755
8860
[SE- 0300 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
8861
+ [SE- 0302 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md>
8756
8862
[SE- 0306 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
8757
8863
[SE- 0310 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
8758
8864
[SE- 0311 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
8759
8865
[SE- 0313 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
8760
8866
[SE- 0315 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
8761
8867
[SE- 0316 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8868
+ [SE- 0322 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
8762
8869
[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
8763
8870
[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
8871
+ [SE- 0331 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
8872
+ [SE- 0337 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
8873
+ [SE- 0335 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
8764
8874
8765
8875
[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
8766
8876
[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments