@@ -324,6 +324,7 @@ func testGlobalActorFuncValue(_ fn: @RedActor () -> Void) async {
324
324
}
325
325
326
326
func acceptAsyncSendableClosureInheriting< T> ( @_inheritActorContext _: @Sendable ( ) async -> T ) { }
327
+ func acceptAsyncSendableClosureAlwaysInheriting< T> ( @_inheritActorContext ( always) _: @Sendable ( ) async -> T ) { }
327
328
328
329
extension MyActor {
329
330
func synchronous( ) { }
@@ -338,6 +339,50 @@ extension MyActor {
338
339
synchronous ( )
339
340
}
340
341
}
342
+
343
+ // CHECK-LABEL: sil private [ossa] @$s4test7MyActorC0A16AlwaysInheritingyyFyyYaYbXEfU_
344
+ // CHECK: debug_value [[SELF:%[0-9]+]] : $MyActor
345
+ // CHECK-NEXT: [[COPY:%[0-9]+]] = copy_value [[SELF]] : $MyActor
346
+ // CHECK-NEXT: [[BORROW:%[0-9]+]] = begin_borrow [[COPY]] : $MyActor
347
+ // CHECK-NEXT: hop_to_executor [[BORROW]] : $MyActor
348
+ func testAlwaysInheriting( ) {
349
+ acceptAsyncSendableClosureAlwaysInheriting {
350
+ }
351
+ }
352
+ }
353
+
354
+ func testIsolatedParameterWithInheritActorContext( _ isolation: isolated ( any Actor ) ? ) {
355
+ // CHECK-LABEL: sil private [ossa] @$s4test0A40IsolatedParameterWithInheritActorContextyyScA_pSgYiFyyYaYbXEfU_
356
+ // CHECK: debug_value [[ISOLATION:%[0-9]+]] : $Optional<any Actor>
357
+ // CHECK-NEXT: [[COPY:%[0-9]+]] = copy_value [[ISOLATION]] : $Optional<any Actor>
358
+ // CHECK-NEXT: [[BORROW:%[0-9]+]] = begin_borrow [[COPY]] : $Optional<any Actor>
359
+ // CHECK-NEXT: hop_to_executor [[BORROW]] : $Optional<any Actor>
360
+ acceptAsyncSendableClosureAlwaysInheriting {
361
+ }
362
+
363
+ // CHECK-LABEL: sil private [ossa] @$s4test0A40IsolatedParameterWithInheritActorContextyyScA_pSgYiFyyYaYbScMYcXEfU0_
364
+ // CHECK: hop_to_executor {{.*}} : $MainActor
365
+ acceptAsyncSendableClosureAlwaysInheriting { @MainActor in
366
+ // CHECK-LABEL: sil private [ossa] @$s4test0A40IsolatedParameterWithInheritActorContextyyScA_pSgYiFyyYaYbScMYcXEfU0_yyYaYbXEfU_
367
+ // CHECK: hop_to_executor {{.*}} : $MainActor
368
+ acceptAsyncSendableClosureAlwaysInheriting {
369
+ }
370
+ }
371
+
372
+ // CHECK-LABEL: sil private [ossa] @$s4test0A40IsolatedParameterWithInheritActorContextyyScA_pSgYiFyyYaYbXEfU1_
373
+ // CHECK: debug_value [[ISOLATION:%[0-9]+]] : $Optional<any Actor>
374
+ // CHECK-NEXT: [[COPY:%[0-9]+]] = copy_value [[ISOLATION]] : $Optional<any Actor>
375
+ // CHECK-NEXT: [[BORROW:%[0-9]+]] = begin_borrow [[COPY]] : $Optional<any Actor>
376
+ // CHECK-NEXT: hop_to_executor [[BORROW]] : $Optional<any Actor>
377
+ acceptAsyncSendableClosureAlwaysInheriting {
378
+ // CHECK-LABEL: sil private [ossa] @$s4test0A40IsolatedParameterWithInheritActorContextyyScA_pSgYiFyyYaYbXEfU1_yyYaYbXEfU_
379
+ // CHECK: debug_value [[ISOLATION:%[0-9]+]] : $Optional<any Actor>
380
+ // CHECK-NEXT: [[COPY:%[0-9]+]] = copy_value [[ISOLATION]] : $Optional<any Actor>
381
+ // CHECK-NEXT: [[BORROW:%[0-9]+]] = begin_borrow [[COPY]] : $Optional<any Actor>
382
+ // CHECK-NEXT: hop_to_executor [[BORROW]] : $Optional<any Actor>
383
+ acceptAsyncSendableClosureAlwaysInheriting {
384
+ }
385
+ }
341
386
}
342
387
343
388
func acceptAsyncClosure( _: ( ) async -> Void ) { }
0 commit comments