|
| 1 | +// RUN: %target-swift-frontend -typecheck %s -enable-experimental-feature OptionalIsolatedParameters -verify |
| 2 | + |
| 3 | +// RUN: %target-swift-frontend -dump-ast %s -enable-experimental-feature OptionalIsolatedParameters | %FileCheck %s |
| 4 | + |
| 5 | +// REQUIRES: concurrency |
| 6 | +// REQUIRES: asserts |
| 7 | +// REQUIRES: distributed |
| 8 | + |
| 9 | +import Distributed |
| 10 | + |
| 11 | +@available(SwiftStdlib 5.7, *) |
| 12 | +extension DistributedActor { |
| 13 | + // CHECK-LABEL: actorIsolationToSelf() |
| 14 | + func actorIsolationToSelf() { |
| 15 | + // CHECK: macro_expansion_expr |
| 16 | + // CHECK: rewritten=current_context_isolation_expr |
| 17 | + // CHECK-NEXT: inject_into_optional |
| 18 | + // CHECK: member_ref_expr{{.*}}asLocalActor |
| 19 | + // CHECK: declref_expr implicit type="Self" |
| 20 | + _ = #isolation |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +// CHECK-LABEL: actorIsolationToParam(_:) |
| 25 | +@available(SwiftStdlib 5.7, *) |
| 26 | +func actorIsolationToParam(_ isolatedParam: isolated any DistributedActor) { |
| 27 | + // CHECK: macro_expansion_expr |
| 28 | + // CHECK: rewritten=current_context_isolation_expr |
| 29 | + // CHECK: member_ref_expr{{.*}}asLocalActor |
| 30 | + _ = #isolation |
| 31 | +} |
| 32 | + |
| 33 | +func acceptClosure(_ body: () -> Void) { } |
| 34 | + |
| 35 | +// CHECK-LABEL: closureIsolatedToOuterParam( |
| 36 | +@available(SwiftStdlib 5.7, *) |
| 37 | +func closureIsolatedToOuterParam(_ isolatedParam: isolated any DistributedActor) { |
| 38 | + // CHECK: closure_expr |
| 39 | + // CHECK: macro_expansion_expr |
| 40 | + // CHECK: rewritten=current_context_isolation_expr |
| 41 | + // CHECK: inject_into_optional |
| 42 | + // CHECK: member_ref_expr{{.*}}asLocalActor |
| 43 | + acceptClosure { |
| 44 | + _ = #isolation |
| 45 | + print(isolatedParam) |
| 46 | + } |
| 47 | +} |
0 commit comments