Skip to content

Commit 4b7e5e5

Browse files
authored
Merge pull request #41951 from DougGregor/unnamed-isolated-params-5.6
Ensure that emit unnamed isolated parameters
2 parents b2a2a76 + 3c4e0d3 commit 4b7e5e5

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
@@ -314,7 +314,7 @@ struct ArgumentInitHelper {
314314
assert(type->isMaterializable());
315315

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

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)