@@ -428,6 +428,52 @@ extension MyActor {
428428 }
429429}
430430
431+ /*-- Generic actors --*/
432+
433+ actor GenericActor < T> {
434+ func asyncAction( ) async { }
435+ }
436+
437+ // CHECK-LABEL: sil hidden [ossa] @$s4test12GenericActorC0a5ErasebC0yyF
438+ // CHECK: // function_ref closure #1
439+ // CHECK-NEXT: [[CLOSURE_FN:%.*]] = function_ref @$s4test12GenericActorC0a5ErasebC0yyFyyYaYbcfU_ : $@convention(thin) @Sendable @async <τ_0_0> (@guaranteed Optional<any Actor>, @sil_isolated @guaranteed GenericActor<τ_0_0>) -> ()
440+ // CHECK-NEXT: [[CAPTURE:%.*]] = copy_value %0 : $GenericActor<T>
441+ // CHECK-NEXT: [[CAPTURE_FOR_ISOLATION:%.*]] = copy_value [[CAPTURE]] : $GenericActor<T>
442+ // CHECK-NEXT: [[ISOLATION_OBJECT:%.*]] = init_existential_ref [[CAPTURE_FOR_ISOLATION]] : $GenericActor<T> : $GenericActor<T>, $any Actor
443+ // CHECK-NEXT: [[ISOLATION:%.*]] = enum $Optional<any Actor>, #Optional.some!enumelt, [[ISOLATION_OBJECT]] : $any Actor
444+ // CHECK-NEXT: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[CLOSURE_FN]]<T>([[ISOLATION]], [[CAPTURE]])
445+ // CHECK-NEXT: // function_ref
446+ // CHECK-NEXT: [[TAKE_FN:%.*]] = function_ref @$s4test30takeInheritingAsyncIsolatedAny2fnyyyYaYbYAc_tF
447+ // CHECK-NEXT: apply [[TAKE_FN]]([[CLOSURE]])
448+ // CHECK-NEXT: destroy_value [[CLOSURE]]
449+ extension GenericActor {
450+ func testEraseGenericActor( ) {
451+ takeInheritingAsyncIsolatedAny {
452+ await self . asyncAction ( )
453+ }
454+ }
455+ }
456+
457+ // CHECK-LABEL: sil hidden [ossa] @$s4test12GenericActorCAASiRszlE0a16EraseSpecializedbC0yyF
458+ // CHECK: // function_ref closure #1
459+ // CHECK-NEXT: [[CLOSURE_FN:%.*]] = function_ref @$s4test12GenericActorCAASiRszlE0a16EraseSpecializedbC0yyFyyYaYbcfU_ : $@convention(thin) @Sendable @async (@guaranteed Optional<any Actor>, @sil_isolated @guaranteed GenericActor<Int>) -> ()
460+ // CHECK-NEXT: [[CAPTURE:%.*]] = copy_value %0 : $GenericActor<Int>
461+ // CHECK-NEXT: [[CAPTURE_FOR_ISOLATION:%.*]] = copy_value [[CAPTURE]] : $GenericActor<Int>
462+ // CHECK-NEXT: [[ISOLATION_OBJECT:%.*]] = init_existential_ref [[CAPTURE_FOR_ISOLATION]] : $GenericActor<Int> : $GenericActor<Int>, $any Actor
463+ // CHECK-NEXT: [[ISOLATION:%.*]] = enum $Optional<any Actor>, #Optional.some!enumelt, [[ISOLATION_OBJECT]] : $any Actor
464+ // CHECK-NEXT: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[CLOSURE_FN]]([[ISOLATION]], [[CAPTURE]])
465+ // CHECK-NEXT: // function_ref
466+ // CHECK-NEXT: [[TAKE_FN:%.*]] = function_ref @$s4test30takeInheritingAsyncIsolatedAny2fnyyyYaYbYAc_tF
467+ // CHECK-NEXT: apply [[TAKE_FN]]([[CLOSURE]])
468+ // CHECK-NEXT: destroy_value [[CLOSURE]]
469+ extension GenericActor where T == Int {
470+ func testEraseSpecializedGenericActor( ) {
471+ takeInheritingAsyncIsolatedAny {
472+ await self . asyncAction ( )
473+ }
474+ }
475+ }
476+
431477/*-- Partial applications --*/
432478
433479// FIXME: this is wrong; we need to capture the actor value
0 commit comments