55
66## Swift 6.0
77
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+
824* [ SE-0428] [ ] :
925 Distributed actors now have the ability to support complete split server /
1026 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:
5066```
5167
5268* [ 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
5470 implemented by custom executor implementations in order to provide a last resort
5571 check before the isolation asserting APIs such as ` Actor.assumeIsolated ` or
5672 ` assertIsolated ` fail and crash.
@@ -59,6 +75,34 @@ And the module structure to support such applications looks like this:
5975 checking, and now even an actor which is "on a queue which is targeting
6076 another specific queue" can be properly detected using these APIs.
6177
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+
62106* [ SE-0423] [ ] :
63107 You can now use ` @preconcurrency ` attribute to replace static actor isolation
64108 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:
99143 The dynamic actor isolation checks can be disabled using the flag
100144 ` -disable-dynamic-actor-isolation ` .
101145
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+
102161* [ SE-0418] [ ] :
103162
104163 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
1049610555[SE- 0407 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
1049710556[SE- 0408 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
1049810557[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
1050010558[SE- 0412 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md
1050110559[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
1050210564[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
1050310566[SE- 0427 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
1050410567[SE- 0429 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
1050510568[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
1050710569[SE- 0430 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md
1050810570[SE- 0418 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md
1050910571[SE- 0423 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md
1051010572[SE- 0424 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0424-custom-isolation-checking-for-serialexecutor.md
1051110573[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
1051210575[#64927 ]: < https: // github.com/apple/swift/issues/64927>
1051310576[#42697 ]: < https: // github.com/apple/swift/issues/42697>
1051410577[#42728 ]: < https: // github.com/apple/swift/issues/42728>
0 commit comments