5
5
6
6
## Swift 6.0
7
7
8
+ * Swift 6 comes with a new language mode that prevents the risk of data races
9
+ at compile time. This guarantee is accomplished through _ data isolation_ ; the
10
+ compiler will validate that data passed over a boundary between concurrently
11
+ executing code is either safe to reference concurrently, or mutually
12
+ exclusive access to the value is enforced.
13
+
14
+ The data-race safety checks were previously available in Swift 5.10 through
15
+ the ` -strict-concurrency=complete ` compiler flag. Complete concurrency
16
+ checking in Swift 5.10 was overly restrictive, and Swift 6 removes many
17
+ false-positive data-race warnings through better ` Sendable ` inference,
18
+ new analysis that proves mutually exclusive access when passing values with
19
+ non-` Sendable ` type over isolation boundaries, and more.
20
+
21
+ You can enable the Swift 6 language mode using the ` -swift-version 6 `
22
+ compiler flag.
23
+
8
24
* [ SE-0428] [ ] :
9
25
Distributed actors now have the ability to support complete split server /
10
26
client systems, thanks to the new ` @Resolvable ` macro and runtime changes.
@@ -50,7 +66,7 @@ And the module structure to support such applications looks like this:
50
66
```
51
67
52
68
* [ SE-0424] [ ] :
53
- Serial executor gain a new customization point ` checkIsolation() ` , which can be
69
+ Serial executor gains a new customization point ` checkIsolation() ` , which can be
54
70
implemented by custom executor implementations in order to provide a last resort
55
71
check before the isolation asserting APIs such as ` Actor.assumeIsolated ` or
56
72
` assertIsolated ` fail and crash.
@@ -59,6 +75,34 @@ And the module structure to support such applications looks like this:
59
75
checking, and now even an actor which is "on a queue which is targeting
60
76
another specific queue" can be properly detected using these APIs.
61
77
78
+ * [ SE-0431] [ ] :
79
+ You can now require a function value to carry its actor isolation
80
+ dynamically in a way that can be directly read by clients:
81
+
82
+ ``` swift
83
+ func apply <R >(count : Int ,
84
+ operation : @isolated (any) async () -> R) async -> [R]
85
+ where R: Sendable {
86
+ // implementation
87
+ }
88
+ ```
89
+
90
+ The isolation can read with the ` .isolation ` property, which has type
91
+ ` (any Actor)? ` :
92
+
93
+ ``` swift
94
+ let iso = operation.isolation
95
+ ```
96
+
97
+ This capability has been adopted by the task-creation APIs in the
98
+ standard library. As a result, creating a task with an actor-isolated
99
+ function will now synchronously enqueue the task on the actor, which
100
+ can be used for transitive event-ordering guarantees if the actor
101
+ guarantees that jobs will be run in the order they are enqueued, as
102
+ ` @MainActor ` does. If the function is not explicitly isolated, Swift
103
+ still retains the right to optimize enqueues for functions that actually
104
+ start by doing work with different isolation from their formal isolation.
105
+
62
106
* [ SE-0423] [ ] :
63
107
You can now use ` @preconcurrency ` attribute to replace static actor isolation
64
108
checking with dynamic checks for witnesses of synchronous nonisolated protocol
@@ -99,6 +143,21 @@ And the module structure to support such applications looks like this:
99
143
The dynamic actor isolation checks can be disabled using the flag
100
144
` -disable-dynamic-actor-isolation ` .
101
145
146
+ * [ SE-0420] [ ] :
147
+ ` async ` functions can now explicitly inherit the isolation of their caller
148
+ by declaring an ` isolated ` parameter with the default value of ` #isolation ` :
149
+
150
+ ``` swift
151
+ func poll (isolation : isolated (any Actor)? = #isolation ) async -> [Item] {
152
+ // implementation
153
+ }
154
+ ```
155
+
156
+ When the caller is actor-isolated, this allows it to pass isolated state
157
+ to the function, which would otherwise have concurrency problems. The
158
+ function may also be able to eliminate unwanted scheduling changes, such
159
+ as when it can quickly return in a fast path without needing to suspend.
160
+
102
161
* [ SE-0418] [ ] :
103
162
104
163
The compiler would now automatically employ ` Sendable ` on functions
@@ -10496,19 +10555,23 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
10496
10555
[SE- 0407 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
10497
10556
[SE- 0408 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
10498
10557
[SE- 0411 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0411-isolated-default-values.md
10499
- [SE- 0417 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md
10500
10558
[SE- 0412 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md
10501
10559
[SE- 0413 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
10560
+ [SE- 0414 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md
10561
+ [SE- 0417 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md
10562
+ [SE- 0418 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
10563
+ [SE- 0420 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0420-inheritance-of-actor-isolation.md
10502
10564
[SE- 0422 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
10565
+ [SE- 0423 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md
10503
10566
[SE- 0427 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
10504
10567
[SE- 0429 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
10505
10568
[SE- 0432 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
10506
- [SE- 0414 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md
10507
10569
[SE- 0430 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md
10508
10570
[SE- 0418 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
10509
10571
[SE- 0423 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md
10510
10572
[SE- 0424 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0424-custom-isolation-checking-for-serialexecutor.md
10511
10573
[SE- 0428 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0428-resolve-distributed-actor-protocols.md
10574
+ [SE- 0431 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0431-isolated-any-functions.md
10512
10575
[#64927 ]: < https: // github.com/apple/swift/issues/64927>
10513
10576
[#42697 ]: < https: // github.com/apple/swift/issues/42697>
10514
10577
[#42728 ]: < https: // github.com/apple/swift/issues/42728>
0 commit comments