@@ -582,3 +582,35 @@ bb0:
582
582
%12 = tuple ()
583
583
return %12 : $()
584
584
} // end sil function 'testGenericClosureSpecialization'
585
+
586
+ // Test a specialization of a self-recursive generic closure.
587
+
588
+ // CHECK-LABEL: sil shared @_T027selfReferringGenericClosurexBi64_Bi64_Bi64_Rs_r0_lItnny_Tp5 : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_1 == Builtin.Int64> (@in_guaranteed τ_0_0, @in_guaranteed Builtin.Int64, Builtin.Int64) -> ()
589
+ // CHECK: [[SPECIALIZED_FN:%[0-9]+]] = function_ref @_T027selfReferringGenericClosurexBi64_Bi64_Bi64_Rs_r0_lItnny_Tp5
590
+ // CHECK: partial_apply [[SPECIALIZED_FN]]{{.*}}({{.*}}) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_1 == Builtin.Int64> (@in_guaranteed τ_0_0, @in_guaranteed Builtin.Int64, Builtin.Int64) -> ()
591
+
592
+ // CHECK-LABEL: sil @selfReferringGenericClosure : $@convention(thin) <R, S> (@in_guaranteed R, @in_guaranteed S, Builtin.Int64) -> ()
593
+ // Refer to the specialized version of the function
594
+ // CHECK: [[SPECIALIZED_FN:%[0-9]+]] = function_ref @_T027selfReferringGenericClosurexBi64_Bi64_Bi64_Rs_r0_lItnny_Tp5
595
+ // CHECK: partial_apply [[SPECIALIZED_FN]]<R>({{.*}}) : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_1 == Builtin.Int64> (@in_guaranteed τ_0_0, @in_guaranteed Builtin.Int64, Builtin.Int64) -> ()
596
+ sil @selfReferringGenericClosure : $@convention(thin) <R, S> (@in_guaranteed R, @in_guaranteed S, Builtin.Int64) -> () {
597
+ bb0(%0 : $*R, %1 : $*S, %2 : $Builtin.Int64):
598
+ %4 = integer_literal $Builtin.Int64, 100
599
+ %5 = builtin "cmp_eq_Int64"(%2 : $Builtin.Int64, %4 : $Builtin.Int64) : $Builtin.Int1
600
+ cond_br %5, bb2, bb1
601
+
602
+ bb1:
603
+ %val_storage = alloc_stack $Builtin.Int64
604
+ %val = integer_literal $Builtin.Int64, 4
605
+ store %val to %val_storage : $*Builtin.Int64
606
+ %fn = function_ref @selfReferringGenericClosure : $@convention(thin) <U, V> (@in_guaranteed U, @in_guaranteed V, Builtin.Int64) -> ()
607
+ %7 = partial_apply %fn<R, Builtin.Int64>(%0, %val_storage, %4) : $@convention(thin) <U, V> (@in_guaranteed U, @in_guaranteed V, Builtin.Int64) -> ()
608
+ dealloc_stack %val_storage : $*Builtin.Int64
609
+ br bb3
610
+ bb2:
611
+ br bb3
612
+
613
+ bb3:
614
+ %8 = tuple ()
615
+ return %8 : $()
616
+ }
0 commit comments