@@ -164,25 +164,39 @@ concurrency checking.
164164
165165* [ SE-0411] [ ] :
166166
167- Default value expressions can now have the same isolation as the enclosing
168- function or the corresponding stored property:
167+ Swift 5.10 closes a data-race safety hole that previously permitted isolated
168+ default stored property values to be synchronously evaluated from outside the
169+ actor. For example, the following code compiles warning-free under
170+ ` -strict-concurrency=complete ` in Swift 5.9, but it will crash at runtime at
171+ the call to ` MainActor.assertIsolated() ` :
169172
170173 ``` swift
171- @MainActor
172- func requiresMainActor () -> Int { ... }
174+ @MainActor func requiresMainActor () -> Int {
175+ MainActor.assertIsolated ()
176+ return 0
177+ }
173178
174- class C {
175- @MainActor
176- var x : Int = requiresMainActor ()
179+ @MainActor struct S {
180+ var x = requiresMainActor ()
181+ var y : Int
177182 }
178183
179- @MainActor func defaultArg (value : Int = requiresMainActor ()) { ... }
184+ nonisolated func call () async {
185+ let s = await S (y : 10 )
186+ }
187+
188+ await call ()
180189 ```
181190
182- For isolated default values of stored properties, the implicit initialization
183- only happens in the body of an ` init ` with the same isolation. This closes
184- an important data-race safety hole where global-actor-isolated default values
185- could inadvertently run synchronously from outside the actor.
191+ This happens because ` requiresMainActor() ` is used as a default argument to
192+ the member-wise initializer of ` S ` , but default arguments are always
193+ evaluated in the caller. In this case, the caller runs on the generic
194+ executor, so the default argument evaluation crashes.
195+
196+ Under ` -strict-concurrency=complete ` in Swift 5.10, default argument values
197+ can safely share the same isolation as the enclosing function or stored
198+ property. The above code is still valid, but the isolated default argument is
199+ guaranteed to be evaluated in the callee's isolation domain.
186200
187201## Swift 5.9.2
188202
0 commit comments