Skip to content

Commit b668f95

Browse files
committed
trying to get compatibility right
1 parent 827ae01 commit b668f95

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/Sema/DerivedConformances.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,7 @@ ValueDecl *DerivedConformance::getDerivableRequirement(NominalTypeDecl *nominal,
335335

336336
// Actor.unownedExecutor
337337
if (name.isSimpleName(ctx.Id_unownedExecutor)) {
338-
// if (nominal->isDistributedActor()) {
339-
// return getRequirement(KnownProtocolKind::DistributedActor);
340-
// } else {
341-
return getRequirement(KnownProtocolKind::Actor);
342-
// }
338+
return getRequirement(KnownProtocolKind::Actor);
343339
}
344340

345341
// DistributedActor.id

stdlib/public/Distributed/DistributedActor.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,24 @@ public protocol DistributedActor: AnyActor, Identifiable, Hashable
303303

304304
}
305305

306-
#if swift(>=5.9.0)
307-
@available(SwiftStdlib 5.9, *)
306+
#if compiler(>=5.9.0) // since this compiler version, we synthesize the `localUnownedExecutor` instead.
307+
@available(SwiftStdlib 5.7, *)
308308
extension DistributedActor {
309-
@available(SwiftStdlib 5.9, *)
309+
@available(SwiftStdlib 5.7, *)
310310
public nonisolated var unownedExecutor: UnownedSerialExecutor {
311+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
312+
// In these versions, we moved to asking developers to implement
313+
// `localUnownedExecutor` and as such delegate to it. The `??` fallback
314+
// is likely to never be triggered, but technically could be if someone queried
315+
// the `unownedExecutor` property directly on a default distributed remote actor reference,
316+
// in previous language versions, so we keep these semantics for compatibility.
311317
return self.localUnownedExecutor ??
312318
UnownedSerialExecutor(Builtin.buildDefaultActorExecutorRef(self))
319+
} else {
320+
// pessimistic reimplementation of the semantics the synthesized body would have had.
321+
// semantically, this is the only implementation possible on older Swift's here.
322+
return UnownedSerialExecutor(Builtin.buildDefaultActorExecutorRef(self))
323+
}
313324
}
314325
}
315326
#endif // swift 5.9

0 commit comments

Comments
 (0)