Skip to content

Commit 641d896

Browse files
committed
[Distributed] Use distributed thunk witnesses for DA protocol extensions.
When a distributed member of an extension of a DistributedActor protocol is used to satisfy a distributed requirement for the same protocol, make sure we still use the distributed thunk. Noticed by inspection.
1 parent 5191c31 commit 641d896

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,10 +707,6 @@ SILFunction *SILGenModule::emitProtocolWitness(
707707
!requirement.getFuncDecl()->isDistributed() &&
708708
witnessRef.hasDecl() && witnessRef.getFuncDecl() &&
709709
witnessRef.getFuncDecl()->isDistributed());
710-
// We only need to use thunks when we go cross-actor:
711-
shouldUseDistributedThunkWitness = shouldUseDistributedThunkWitness &&
712-
getActorIsolation(requirement.getDecl()) !=
713-
getActorIsolation(witness.getDecl());
714710
if (shouldUseDistributedThunkWitness) {
715711
auto thunkDeclRef = SILDeclRef(
716712
witnessRef.getFuncDecl()->getDistributedThunk(),

test/SILGen/distributed_thunk.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,29 @@ distributed actor DA4: ServerProto {
5959
// CHECK: function_ref @$s17distributed_thunk3DA4C11doSomethingyyYaKFTE
6060
distributed func doSomething() throws { }
6161
}
62+
63+
protocol Server2: DistributedActor {
64+
distributed func sayHello()
65+
}
66+
67+
extension Server2 where ActorSystem == LocalTestingDistributedActorSystem {
68+
// CHECK-LABEL: sil hidden [thunk] [distributed] [ref_adhoc_requirement_witness "$s11Distributed29LocalTestingInvocationDecoderC18decodeNextArgumentxyKSeRzSERzlF"] [ossa] @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyYaKFTE
69+
// CHECK-NOT: return
70+
// CHECK: function_ref @swift_distributed_actor_is_remote
71+
distributed func sayHello() { /* default impl */ }
72+
73+
// CHECK-LABEL: sil hidden [distributed] [ossa] @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyF
74+
// CHECK-NOT: swift_distributed_actor_is_remote
75+
// CHECK: return
76+
}
77+
78+
distributed actor DA5: Server2 {
79+
typealias ActorSystem = LocalTestingDistributedActorSystem
80+
// uses default impl
81+
82+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s17distributed_thunk3DA5CAA7Server2A2aDP8sayHelloyyFTW
83+
// CHECK: function_ref @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyF
84+
85+
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s17distributed_thunk3DA5CAA7Server2A2aDP8sayHelloyyFTWTE
86+
// CHECK: function_ref @$s17distributed_thunk7Server2PAA11Distributed012LocalTestingD11ActorSystemC0gH0RtzrlE8sayHelloyyYaKFTE
87+
}

0 commit comments

Comments
 (0)