Skip to content

Commit 14fc015

Browse files
committed
Ensure that we map the capture isolation into context
Failing to map the type of an isolation capture into context caused assertions in type lowering. Fixes the build of the swift-distributed-actors package.
1 parent 96fd043 commit 14fc015

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/SILGen/SILGenConcurrency.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ static ManagedValue emitLoadOfCaptureIsolation(SILGenFunction &SGF,
463463
auto &TC = SGF.SGM.Types;
464464
auto captureInfo = TC.getLoweredLocalCaptures(constant);
465465

466-
auto isolatedVarType =
467-
isolatedCapture->getInterfaceType()->getCanonicalType();
466+
auto isolatedVarType = SGF.F.mapTypeIntoContext(
467+
isolatedCapture->getInterfaceType())->getCanonicalType();
468468

469469
// Capture arguments are 1-1 with the lowered capture info.
470470
auto captures = captureInfo.getCaptures();

test/Distributed/distributed_actor_to_actor.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// rdar://123970272
1010
// UNSUPPORTED: CPU=arm64e
1111

12+
import Swift
1213
import _Concurrency
1314
import Distributed
1415

@@ -39,6 +40,25 @@ func getAnyActor(distributedActor: isolated some DistributedActor) -> any Actor
3940
// CHECK-IR-NEXT: store ptr %"some DistributedActor.DistributedActor", ptr [[SELF_DA_REQ]]
4041
// CHECK-IR-NEXT: call ptr @swift_getWitnessTable(ptr @"$sxScA11DistributedMc", ptr %"some DistributedActor", ptr [[CONDITIONAL_REQ_GEP]])
4142

43+
distributed actor WorkerPool<Worker, ActorSystem: DistributedActorSystem>: AsyncSequence, AsyncIteratorProtocol {
44+
var level: Int
45+
public init(actorSystem system: ActorSystem) async throws {
46+
self.actorSystem = system
47+
self.level = 0
48+
49+
// CHECK-SIL: sil private @$s021distributed_actor_to_B010WorkerPoolC0B6SystemACyxq_Gq__tYaKcfcyyYaYbcfU_ : $@convention(thin) @Sendable @async <Worker, ActorSystem where ActorSystem : DistributedActorSystem> (@guaranteed Optional<any Actor>, @sil_isolated @guaranteed WorkerPool<Worker, ActorSystem>) -> @out
50+
// CHECK-SIL: hop_to_executor {{%.*}} : $WorkerPool<Worker, ActorSystem>
51+
_ = Task {
52+
for await x in self {
53+
print(x)
54+
}
55+
}
56+
}
57+
58+
nonisolated func makeAsyncIterator() -> WorkerPool { self }
59+
nonisolated func next() async -> Int? { nil }
60+
}
61+
4262
// CHECK-SIL-LABEL: sil_witness_table shared <Self where Self : DistributedActor> T: Actor module Distributed {
4363
// CHECK-SIL-NEXT: method #Actor.unownedExecutor!getter: <Self where Self : Actor> (Self) -> () -> UnownedSerialExecutor : @$sxScA11DistributedScA15unownedExecutorScevgTW
4464
// CHECK-SIL-NEXT: conditional_conformance (Self: DistributedActor): dependent

0 commit comments

Comments
 (0)