Files
swift-mirror/test/Distributed/distributed_actor_sending_thunks.swift
Konrad `ktoso` Malawski e650dc00df [Distributed] Distributed thunks take parameters as 'sending'
This is in order to avoid errors in complete concurrency checking mnode
in distributed funcs, or rather their thunks, as there is isolation
boundary crossing happening when we pass a value to a distributed func.

This is because as we do this, we pass it to a nonisolated thunk:

```
nonisolated func THUNK(param: Thing) {
  if remote {
    ...
  } else {
    await self.realFunc(param)
  }
}
```

So what happens here is that the Thing would become isolated to the
task and we get a bad isolation crossing as we pass it along to the
"real func".

Sending values into the distributed thunk is the right thing to do to
resolve this problem: `nonisolated func THUNK(param: sending Thing) {}`

Resolves rdar://126577527
2024-06-06 12:32:47 +09:00

30 lines
972 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/Inputs/FakeDistributedActorSystems.swift
// RUN: %target-swift-frontend -I %t -emit-sil -strict-concurrency=complete -disable-availability-checking -verify %s -o /dev/null
// REQUIRES: concurrency
// REQUIRES: asserts
// REQUIRES: distributed
import Distributed
import FakeDistributedActorSystems
typealias DefaultDistributedActorSystem = FakeActorSystem
final class NonSendableKlass {}
extension NonSendableKlass : Codable {}
@MainActor func transferToMain<T>(_ t: T) async {}
// ==== ------------------------------------------------------------------------
distributed actor MyDistributedActor {
let x = NonSendableKlass()
distributed func transferActorIsolatedArgIntoClosure(
_ notSendableParamToDistributedFunc: NonSendableKlass) async {}
}