|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/OtherActors.swiftmodule -module-name OtherActors %S/Inputs/OtherActors.swift -disable-availability-checking |
| 3 | +// RUN: %target-swift-emit-silgen -verify -module-name test -I %t -disable-availability-checking -warn-concurrency %s | %FileCheck %s --implicit-check-not=hop_to_executor --enable-var-scope |
| 4 | +// REQUIRES: concurrency |
| 5 | + |
| 6 | +import OtherActors |
| 7 | + |
| 8 | +// CHECK-LABEL: sil hidden [ossa] @$s4test6check1ySi11OtherActors0C11ModuleActorCYaF : $@convention(thin) @async (@guaranteed OtherModuleActor) -> Int { |
| 9 | +// CHECK: bb0([[SELF:%[0-9]+]] : @guaranteed $OtherModuleActor): |
| 10 | +// CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $OtherModuleActor, #OtherModuleActor.a |
| 11 | +// CHECK: [[OLD:%[0-9]+]] = builtin "getCurrentExecutor"() : $Optional<Builtin.Executor> |
| 12 | +// CHECK: hop_to_executor [[SELF]] : $OtherModuleActor |
| 13 | +// CHECK-NEXT: load [trivial] [[REF]] |
| 14 | +// CHECK-NEXT: hop_to_executor [[OLD]] : $Optional<Builtin.Executor> |
| 15 | +// CHECK: } // end sil function '$s4test6check1ySi11OtherActors0C11ModuleActorCYaF' |
| 16 | +func check1(_ actor: OtherModuleActor) async -> Int { |
| 17 | + return await actor.a |
| 18 | +} |
| 19 | + |
| 20 | +func check2(_ actor: isolated OtherModuleActor) -> Int { |
| 21 | + return actor.a |
| 22 | +} |
| 23 | + |
| 24 | +func check3(_ actor: OtherModuleActor) async -> Int { |
| 25 | + return actor.b |
| 26 | +} |
| 27 | + |
| 28 | +// CHECK-LABEL: sil hidden [ossa] @$s4test6check4y11OtherActors17SomeSendableClassCSgAC0C11ModuleActorCSgYaF : $@convention(thin) @async (@guaranteed Optional<OtherModuleActor>) -> @owned Optional<SomeSendableClass> { |
| 29 | +// CHECK: bb0({{%[0-9]+}} : @guaranteed $Optional<OtherModuleActor>): |
| 30 | +// CHECK: switch_enum {{%[0-9]+}} : $Optional<OtherModuleActor>, case #Optional.some!enumelt: [[SOME:bb[0-9]+]], case #Optional.none!enumelt: {{bb[0-9]+}} |
| 31 | + |
| 32 | +// CHECK: [[SOME]]({{%[0-9]+}} : @owned $OtherModuleActor): |
| 33 | +// CHECK: [[REF:%[0-9]+]] = ref_element_addr {{%[0-9]+}} : $OtherModuleActor, #OtherModuleActor.d |
| 34 | +// CHECK: [[OLD:%[0-9]+]] = builtin "getCurrentExecutor"() : $Optional<Builtin.Executor> |
| 35 | +// CHECK: hop_to_executor {{%[0-9]+}} : $OtherModuleActor |
| 36 | +// CHECK-NEXT: load [copy] [[REF]] |
| 37 | +// CHECK: hop_to_executor [[OLD]] : $Optional<Builtin.Executor> |
| 38 | +// CHECK: } // end sil function '$s4test6check4y11OtherActors17SomeSendableClassCSgAC0C11ModuleActorCSgYaF' |
| 39 | +func check4(_ actor: OtherModuleActor?) async -> SomeSendableClass? { |
| 40 | + return await actor?.d |
| 41 | +} |
0 commit comments