Skip to content

Commit 1c1b6f7

Browse files
authored
Merge pull request #74606 from ktoso/wip-whenLocal-adjust
[Distributed] Adjust whenLocal impl to avoid potential ABI issues
2 parents a5ac6aa + 8ea87e4 commit 1c1b6f7

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ extension DistributedActor {
363363
///
364364
/// When the actor is remote, the closure won't be executed and this function will return nil.
365365
@_alwaysEmitIntoClient
366+
// we need to silgen_name here because the signature is the same as __abi_whenLocal,
367+
// and even though this is @AEIC, the symbol name would conflict.
368+
@_silgen_name("$s11Distributed0A5ActorPAAE20whenLocalTypedThrowsyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lF")
366369
public nonisolated func whenLocal<T: Sendable, E>(
367370
_ body: @Sendable (isolated Self) async throws(E) -> T
368371
) async throws(E) -> T? {
@@ -374,6 +377,17 @@ extension DistributedActor {
374377
}
375378
}
376379

380+
// ABI: This is a workaround when in Swift 6 this method was introduced
381+
// in order to support typed-throws, but missed to add @_aeic.
382+
// In practice, this method should not ever be used by anyone, ever.
383+
@usableFromInline
384+
@_silgen_name("$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lF")
385+
internal nonisolated func __abi_whenLocal<T: Sendable, E>(
386+
_ body: @Sendable (isolated Self) async throws(E) -> T
387+
) async throws(E) -> T? {
388+
try await whenLocal(body)
389+
}
390+
377391
// ABI: Historical whenLocal, rethrows was changed to typed throws `throws(E)`
378392
@_silgen_name("$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbKXEYaKs8SendableRd__lF")
379393
@usableFromInline

test/abi/macOS/arm64/distributed.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ Added: _$s11Distributed0A5ActorPAAE22__actorUnownedExecutorScevpMV
104104

105105
// Distributed._distributedStubFatalError(function: Swift.String) -> Swift.Never
106106
Added: _$s11Distributed26_distributedStubFatalError8functions5NeverOSS_tF
107+
108+
// Bin compat for typed throws overload of whenLocal
109+
// (extension in Distributed):Distributed.DistributedActor.whenLocal<A, B where A1: Swift.Sendable, B1: Swift.Error>(@Sendable (isolated A) async throws(B1) -> A1) async throws(B1) -> A1?
110+
Added: _$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lF
111+
// async function pointer to (extension in Distributed):Distributed.DistributedActor.whenLocal<A, B where A1: Swift.Sendable, B1: Swift.Error>(@Sendable (isolated A) async throws(B1) -> A1) async throws(B1) -> A1?
112+
Added: _$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lFTu

test/abi/macOS/x86_64/distributed.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ Added: _$s11Distributed0A5ActorPAAE22__actorUnownedExecutorScevpMV
104104

105105
// Distributed._distributedStubFatalError(function: Swift.String) -> Swift.Never
106106
Added: _$s11Distributed26_distributedStubFatalError8functions5NeverOSS_tF
107+
108+
// Bin compat for typed throws overload of whenLocal
109+
// (extension in Distributed):Distributed.DistributedActor.whenLocal<A, B where A1: Swift.Sendable, B1: Swift.Error>(@Sendable (isolated A) async throws(B1) -> A1) async throws(B1) -> A1?
110+
Added: _$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lF
111+
// async function pointer to (extension in Distributed):Distributed.DistributedActor.whenLocal<A, B where A1: Swift.Sendable, B1: Swift.Error>(@Sendable (isolated A) async throws(B1) -> A1) async throws(B1) -> A1?
112+
Added: _$s11Distributed0A5ActorPAAE9whenLocalyqd__Sgqd__xYiYaYbqd_0_YKXEYaqd_0_YKs8SendableRd__s5ErrorRd_0_r0_lFTu

0 commit comments

Comments
 (0)