Skip to content

Commit 68eab70

Browse files
authored
[Distributed] whenLocal adoption of typed throws (#71439)
1 parent 14649c5 commit 68eab70

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,25 @@ extension DistributedActor {
362362
/// state.
363363
///
364364
/// When the actor is remote, the closure won't be executed and this function will return nil.
365-
public nonisolated func whenLocal<T: Sendable>(
366-
_ body: @Sendable (isolated Self) async throws -> T
367-
) async rethrows -> T? {
365+
public nonisolated func whenLocal<T: Sendable, E>(
366+
_ body: @Sendable (isolated Self) async throws(E) -> T
367+
) async throws(E) -> T? {
368368
if __isLocalActor(self) {
369369
_local let localSelf = self
370370
return try await body(localSelf)
371371
} else {
372372
return nil
373373
}
374374
}
375+
376+
// ABI: Historical whenLocal, rethrows was changed to typed throws `throws(E)`
377+
@_silgen_name("$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbKXEYaKs8SendableRd__lF")
378+
@usableFromInline
379+
nonisolated func __abi_whenLocal<T: Sendable>(
380+
_ body: @Sendable (isolated Self) async throws -> T
381+
) async rethrows -> T? {
382+
try await whenLocal(body)
383+
}
375384
}
376385

377386
/// Supports the operation to produce an any Actor instance from a local

0 commit comments

Comments
 (0)