@@ -19,6 +19,129 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
1919Swift 5.6
2020---------
2121
22+ * Actor isolation checking now understands that ` defer ` bodies share the isolation of their enclosing function.
23+
24+ ``` swift
25+ // Works on global actors
26+ @MainActor
27+ func runAnimation (controller : MyViewController) async {
28+ controller.hasActiveAnimation = true
29+ defer { controller.hasActiveAnimation = false }
30+
31+ // do the animation here...
32+ }
33+
34+ // Works on actor instances
35+ actor OperationCounter {
36+ var activeOperationCount = 0
37+
38+ func operate () async {
39+ activeOperationCount += 1
40+ defer { activeOperationCount -= 1 }
41+
42+ // do work here...
43+ }
44+ }
45+ ```
46+
47+ * [ SE-0335] [ ] :
48+
49+ Swift now allows existential types to be explicitly written with the ` any `
50+ keyword, creating a syntactic distinction between existential types and
51+ protocol conformance constraints. For example:
52+
53+ ``` swift
54+ protocol P {}
55+
56+ func generic <T >(value : T) where T: P {
57+ ...
58+ }
59+
60+ func existential (value : any P) {
61+ ...
62+ }
63+ ```
64+
65+ * [ SE-0337] [ ] :
66+
67+ Swift now provides an incremental migration path to data race safety, allowing
68+ APIs to adopt concurrency without breaking their clients that themselves have
69+ not adopted concurrency. An existing declaration can introduce
70+ concurrency-related annotations (such as making its closure parameters
71+ ` @Sendable ` ) and use the ` @preconcurrency ` attribute to maintain its behavior
72+ for clients who have not themselves adopted concurrency:
73+
74+ ``` swift
75+ // module A
76+ @preconcurrency func runOnSeparateTask (_ workItem : @Sendable () -> Void )
77+
78+ // module B
79+ import A
80+
81+ class MyCounter {
82+ var value = 0
83+ }
84+
85+ func doesNotUseConcurrency (counter : MyCounter) {
86+ runOnSeparateTask {
87+ counter.value += 1 // no warning, because this code hasn't adopted concurrency
88+ }
89+ }
90+
91+ func usesConcurrency (counter : MyCounter) async {
92+ runOnSeparateTask {
93+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
94+ }
95+ }
96+ ```
97+
98+ One can enable warnings about data race safety within a module with the
99+ ` -warn-concurrency ` compiler option. When using a module that does not yet
100+ provide ` Sendable ` annotations, one can suppress warnings for types from that
101+ module by marking the import with ` @preconcurrency ` :
102+
103+ ``` swift
104+ /// module C
105+ public struct Point {
106+ public var x, y: Double
107+ }
108+
109+ // module D
110+ @preconcurrency import C
111+
112+ func centerView (at location : Point) {
113+ Task {
114+ await mainView.center (at : location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
115+ }
116+ }
117+ ```
118+
119+ * [ SE-0302] [ ] :
120+
121+ Swift will now produce warnings to indicate potential data races when
122+ non-` Sendable ` types are passed across actor or task boundaries. For
123+ example:
124+
125+ ``` swift
126+ class MyCounter {
127+ var value = 0
128+ }
129+
130+ func f () -> MyCounter {
131+ let counter = MyCounter ()
132+ Task {
133+ counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
134+ }
135+ return counter
136+ }
137+ ```
138+
139+ * [ SE-0331] [ ] :
140+
141+ The conformance of the unsafe pointer types (e.g., ` UnsafePointer ` ,
142+ ` UnsafeMutableBufferPointer ` ) to the ` Sendable ` protocols has been removed,
143+ because pointers cannot safely be transferred across task or actor boundaries.
144+
22145* References to ` Self ` or so-called "` Self ` requirements" in the type signatures
23146 of protocol members are now correctly detected in the parent of a nested type.
24147 As a result, protocol members that fall under this overlooked case are no longer
@@ -39,7 +162,7 @@ Swift 5.6
39162 // protocol type (use a generic constraint instead).
40163 _ = p.method
41164 }
42- ```
165+ ```
43166
44167* [ SE-0324] [ ] :
45168
@@ -66,6 +189,19 @@ Swift 5.6
66189 }
67190 ```
68191
192+ * [ SE-0322] [ ] :
193+
194+ The standard library now provides a new operation
195+ ` withUnsafeTemporaryAllocation ` which provides an efficient temporarily
196+ allocation within a limited scope, which will be optimized to use stack
197+ allocation when possible.
198+
199+ * [ SE-0320] [ ] :
200+
201+ Dictionaries with keys of any type conforming to the new protocol
202+ ` CodingKeyRepresentable ` can now be encoded and decoded. Formerly, encoding
203+ and decoding was limited to keys of type ` String ` or ` Int ` .
204+
69205* [ SE-0315] [ ] :
70206
71207 Type expressions and annotations can now include "type placeholders" which
@@ -8766,15 +8902,21 @@ Swift 1.0
87668902[SE- 0298 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
87678903[SE- 0299 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
87688904[SE- 0300 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
8905+ [SE- 0302 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md>
87698906[SE- 0306 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
87708907[SE- 0310 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
87718908[SE- 0311 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
87728909[SE- 0313 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
87738910[SE- 0315 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
87748911[SE- 0316 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8912+ [SE- 0320 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0320-codingkeyrepresentable.md>
8913+ [SE- 0322 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
87758914[SE- 0324 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87768915[SE- 0323 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
87778916[SE- 0328 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
8917+ [SE- 0331 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
8918+ [SE- 0337 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
8919+ [SE- 0335 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
87788920
87798921[SR- 75 ]: < https: // bugs.swift.org/browse/SR-75>
87808922[SR- 106 ]: < https: // bugs.swift.org/browse/SR-106>
0 commit comments