Skip to content

Commit 1466afc

Browse files
committed
Ensure that emit unnamed isolated parameters
... because we need to be able to hop to their actors. Fixes rdar://86753732.
1 parent ae1f250 commit 1466afc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ struct ArgumentInitHelper {
316316
assert(type->isMaterializable());
317317

318318
++ArgNo;
319-
if (PD->hasName()) {
319+
if (PD->hasName() || PD->isIsolated()) {
320320
makeArgumentIntoBinding(type, &*f.begin(), PD);
321321
return;
322322
}

test/SILGen/isolated_parameters.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ public actor A {
1010
// CHECK: sil{{.*}} [ossa] @$s4test13takesIsolatedyyAA1ACYiF
1111
@available(SwiftStdlib 5.1, *)
1212
public func takesIsolated(_: isolated A) { }
13+
14+
@available(SwiftStdlib 5.1, *)
15+
public func takeClosureWithIsolatedParam(body: (isolated A) async -> Void) { }
16+
17+
// Emit the unnamed parameter when it's isolated, so that we can hop to it.
18+
// CHECK-LABEL: sil private [ossa] @$s4test0A24ClosureWithIsolatedParamyyFyAA1ACYiYaXEfU_ : $@convention(thin) @async (@guaranteed A)
19+
// CHECK: bb0(%0 : @guaranteed $A):
20+
// CHECK: [[COPY:%.*]] = copy_value %0 : $A
21+
// CHECK-NEXT: [[BORROW:%.*]] = begin_borrow [[COPY]] : $A
22+
// CHECK-NEXT: hop_to_executor [[BORROW]] : $A
23+
@available(SwiftStdlib 5.1, *)
24+
public func testClosureWithIsolatedParam() {
25+
takeClosureWithIsolatedParam { _ in }
26+
}

0 commit comments

Comments
 (0)