|
1 |
| -// RUN: %target-swift-frontend -emit-silgen %s -module-name test -swift-version 5 | %FileCheck %s |
| 1 | +// RUN: %target-swift-frontend -emit-silgen -enable-experimental-feature OptionalIsolatedParameters %s -module-name test -swift-version 5 | %FileCheck %s |
2 | 2 | // REQUIRES: concurrency
|
3 | 3 |
|
4 | 4 | @available(SwiftStdlib 5.1, *)
|
@@ -34,3 +34,34 @@ public func testIsolatedExistential(_ a: isolated Actor) async {
|
34 | 34 | // CHECK: hop_to_executor [[ACTOR_BORROW]] : $any Actor
|
35 | 35 | // CHECK: return
|
36 | 36 | }
|
| 37 | + |
| 38 | +@available(SwiftStdlib 5.1, *) |
| 39 | +nonisolated func suspend() async {} |
| 40 | + |
| 41 | +// CHECK-LABEL: sil{{.*}} [ossa] @$s4test0A16OptionalIsolatedyyAA1ACSgYiYaF |
| 42 | +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional<A>) |
| 43 | +@available(SwiftStdlib 5.1, *) |
| 44 | +public func testOptionalIsolated(_ a: isolated A?) async { |
| 45 | + await suspend() |
| 46 | + // CHECK: [[ACTOR_COPY:%.*]] = copy_value [[ACTOR]] : $Optional<A> |
| 47 | + // CHECK: [[ACTOR_BORROW:%.*]] = begin_borrow [[ACTOR_COPY]] : $Optional<A> |
| 48 | + // CHECK: hop_to_executor [[ACTOR_BORROW]] : $Optional<A> |
| 49 | + // CHECK: [[SUSPEND:%.*]] = function_ref @$s4test7suspendyyYaF : $@convention(thin) @async () -> () |
| 50 | + // CHECK: apply [[SUSPEND]]() : $@convention(thin) @async () -> () |
| 51 | + // CHECK: hop_to_executor [[ACTOR_BORROW]] : $Optional<A> |
| 52 | + // CHECK: return |
| 53 | +} |
| 54 | + |
| 55 | +// CHECK-LABEL: sil{{.*}} [ossa] @$s4test0A27OptionalIsolatedExistentialyyScA_pSgYiYaF |
| 56 | +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional<any Actor>) |
| 57 | +@available(SwiftStdlib 5.1, *) |
| 58 | +public func testOptionalIsolatedExistential(_ a: isolated (any Actor)?) async { |
| 59 | + await suspend() |
| 60 | + // CHECK: [[ACTOR_COPY:%.*]] = copy_value [[ACTOR]] : $Optional<any Actor> |
| 61 | + // CHECK: [[ACTOR_BORROW:%.*]] = begin_borrow [[ACTOR_COPY]] : $Optional<any Actor> |
| 62 | + // CHECK: hop_to_executor [[ACTOR_BORROW]] : $Optional<any Actor> |
| 63 | + // CHECK: [[SUSPEND:%.*]] = function_ref @$s4test7suspendyyYaF : $@convention(thin) @async () -> () |
| 64 | + // CHECK: apply [[SUSPEND]]() : $@convention(thin) @async () -> () |
| 65 | + // CHECK: hop_to_executor [[ACTOR_BORROW]] : $Optional<any Actor> |
| 66 | + // CHECK: return |
| 67 | +} |
0 commit comments