@@ -945,6 +945,48 @@ bb0(%0 : $Builtin.NativeObject, %1 : $Int):
945945 return %r1 : $Int
946946}
947947
948+ //=======================================================================
949+ // dont convert @owned => @guaranteed when there is a dealloc_partial_ref
950+
951+ sil @test_dealloc_partial_ref_callee : $@convention(thin) () -> ((), @error Error)
952+
953+ // CHECK-LABEL: sil hidden @test_dealloc_partial_ref : $@convention(thin) (@owned foo) -> (@owned foo, @error Error) {
954+ // CHECK-NOT: @guaranteed
955+ // CHECK: function_ref @test_dealloc_partial_ref_callee
956+ // CHECK-NOT: @guaranteed
957+
958+ sil hidden @test_dealloc_partial_ref : $@convention(thin) (@owned foo) -> (@owned foo, @error Error) {
959+ bb0(%1 : $foo):
960+ strong_retain %1 : $foo
961+ %f = function_ref @test_dealloc_partial_ref_callee : $@convention(thin) () -> ((), @error Error)
962+ try_apply %f() : $@convention(thin) () -> ((), @error Error), normal bb1, error bb2
963+
964+ bb1(%27 : $()):
965+ strong_release %1 : $foo
966+ return %1 : $foo
967+
968+ bb2(%157 : $Error):
969+ strong_release %1 : $foo
970+ %mt = metatype $@thick foo.Type
971+ dealloc_partial_ref %1 : $foo, %mt : $@thick foo.Type
972+ throw %157 : $Error
973+ }
974+
975+ sil @test_dealloc_partial_ref_caller : $@convention(thin) () -> (@owned foo, @error Error) {
976+ bb0:
977+ %2 = alloc_ref $foo
978+ %3 = function_ref @test_dealloc_partial_ref : $@convention(thin) (@owned foo) -> (@owned foo, @error Error)
979+ try_apply %3(%2) : $@convention(thin) (@owned foo) -> (@owned foo, @error Error), normal bb1, error bb2
980+
981+ bb1(%5 : $foo):
982+ return %5 : $foo
983+
984+ bb2(%7 : $Error):
985+ throw %7 : $Error
986+ }
987+
988+ // CHECK: } // end sil function 'test_dealloc_partial_ref_caller'
989+
948990//======================
949991// @owned => @guaranteed
950992
0 commit comments