1
- // RUN: %target-swift-frontend -emit-silgen %s -module-name initializers -swift-version 5 -enable-experimental-concurrency | %FileCheck --enable-var-scope %s
1
+ // RUN: %target-swift-frontend -emit-silgen %s -module-name initializers -swift-version 5 -enable-experimental-concurrency | %FileCheck %s --enable-var-scope --implicit-check-not=hop_to_executor
2
2
// REQUIRES: concurrency
3
3
4
4
// CHECK: protocol Person {
@@ -57,8 +57,6 @@ enum MyEnum {
57
57
58
58
actor MyActor {
59
59
// CHECK-DAG: sil hidden [ossa] @$s12initializers7MyActorCACyYacfc : $@convention(method) @async (@owned MyActor) -> @owned MyActor
60
- // CHECK-NOT: hop_to_executor
61
- // CHECK-DAG: } // end sil function '$s12initializers7MyActorCACyYacfc'
62
60
init ( ) async { }
63
61
}
64
62
@@ -153,4 +151,48 @@ func makeDog() async {
153
151
// CHECK: } // end sil function '$s12initializers8makeBirbyyYaF'
154
152
func makeBirb( ) async {
155
153
_ = await Birb ( name: " Chirpy " )
154
+ }
155
+
156
+ actor SomeActor {
157
+ var x : Int = 0
158
+
159
+ // NOTE: during SILGen, we don't expect any hop_to_executors in here.
160
+ // The implicit check-not covers that for us. The hops are inserted later.
161
+ init ( ) async { }
162
+
163
+ // CHECK-LABEL: sil hidden [ossa] @$s12initializers9SomeActorC10someMethodyyYaF : $@convention(method) @async (@guaranteed SomeActor) -> () {
164
+ // CHECK: hop_to_executor {{%[0-9]+}} : $SomeActor
165
+ // CHECK: } // end sil function '$s12initializers9SomeActorC10someMethodyyYaF'
166
+ func someMethod( ) async { }
167
+ }
168
+
169
+ // CHECK-LABEL: sil hidden [ossa] @$s12initializers9makeActorAA04SomeC0CyYaF : $@convention(thin) @async () -> @owned SomeActor {
170
+ // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor
171
+ // CHECK: [[INIT:%[0-9]+]] = function_ref @$s12initializers9SomeActorCACyYacfC : $@convention(method) @async (@thick SomeActor.Type) -> @owned SomeActor
172
+ // CHECK: {{%[0-9]+}} = apply [[INIT]]({{%[0-9]+}}) : $@convention(method) @async (@thick SomeActor.Type) -> @owned SomeActor
173
+ // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor
174
+ // CHECK: } // end sil function '$s12initializers9makeActorAA04SomeC0CyYaF'
175
+ @MainActor
176
+ func makeActor( ) async -> SomeActor {
177
+ return await SomeActor ( )
178
+ }
179
+
180
+ // None of the below calls are expected to have a hop before or after the call.
181
+
182
+ func makeActorFromGeneric( ) async -> SomeActor {
183
+ return await SomeActor ( )
184
+ }
185
+
186
+ func callActorMethodFromGeneric( a: SomeActor ) async {
187
+ await a. someMethod ( )
188
+ }
189
+
190
+ @available ( SwiftStdlib 5 . 5 , * )
191
+ func makeActorInTask( ) async {
192
+ Task . detached { await SomeActor ( ) }
193
+ }
194
+
195
+ @available ( SwiftStdlib 5 . 5 , * )
196
+ func callActorMethodInTask( a: SomeActor ) async {
197
+ Task . detached { await a. someMethod ( ) }
156
198
}
0 commit comments