Skip to content

Commit bab9627

Browse files
committed
Test: Add an arbitrary protocol
This helps workaround the lack of Copyable being written on the `@substituted` generic signature in this test, while remaining compatible with any mode of the compiler.
1 parent c5291e7 commit bab9627

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

test/SILOptimizer/closure-lifetime-fixup.sil

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,12 @@ bb0(%0 : @noImplicitCopy @_eagerMove $Int):
349349
return %14 : $Int
350350
}
351351

352-
struct _UnsafeContinuation<T, R> {}
352+
protocol P {}
353+
extension Int: P {}
354+
struct _UnsafeContinuation<T: P, R> {}
353355

354-
sil @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
355-
sil @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
356+
sil @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
357+
sil @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0: P> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
356358

357359
// insertDestroyOfCapturedArguments should not crash on 'undef'
358360
//
@@ -362,22 +364,22 @@ sil @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0> (@guaranteed @no
362364
sil hidden [ossa] @testCapturedUndef : $@convention(thin) (Int) -> (Int, @error any Error) {
363365
bb0(%0 : $Int):
364366
%5 = alloc_stack $Int
365-
%6 = function_ref @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
366-
%7 = partial_apply [callee_guaranteed] %6(undef) : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
367-
%8 = convert_escape_to_noescape [not_guaranteed] %7 : $@callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int> to $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
368-
destroy_value %7 : $@callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
367+
%6 = function_ref @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
368+
%7 = partial_apply [callee_guaranteed] %6(undef) : $@convention(thin) @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
369+
%8 = convert_escape_to_noescape [not_guaranteed] %7 : $@callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int> to $@noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
370+
destroy_value %7 : $@callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
369371

370-
%10 = function_ref @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
371-
try_apply %10<Int>(%5, %8) : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error), normal bb1, error bb2
372+
%10 = function_ref @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0: P> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
373+
try_apply %10<Int>(%5, %8) : $@convention(thin) <τ_0_0: P> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error), normal bb1, error bb2
372374

373375
bb1(%12 : $()):
374-
destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
376+
destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
375377
%15 = load [trivial] %5 : $*Int
376378
dealloc_stack %5 : $*Int
377379
return %15 : $Int
378380

379381
bb2(%19 : @owned $any Error):
380-
destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
382+
destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0: P> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
381383
dealloc_stack %5 : $*Int
382384
throw %19 : $any Error
383385
}

0 commit comments

Comments
 (0)