mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
- Fix block to func reabstraction thunks block argument handling - Forward cast ownership - Fix applyPartiallyAppliedSuperMethod ownership for @callee_guaranteed closures - Avoid a copy in buildBlockToFuncThunkBody - Update tests for callee_guaranteed closures SR-5441 rdar://33255593
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen %s | %FileCheck %s
|
|
|
|
infix operator ~> { precedence 255 associativity left }
|
|
|
|
protocol P { }
|
|
|
|
func bar<T:P>(_: inout T) -> () -> () { return {_ in ()} }
|
|
func baz<T:P>(_: inout T) -> (Int) -> () { return {_ in ()} }
|
|
|
|
func ~> <T: P, Args, Result>(
|
|
x: inout T,
|
|
m: (_ x: inout T) -> ((Args) -> Result)
|
|
) -> ((Args) -> Result) {
|
|
return m(&x)
|
|
}
|
|
|
|
struct X : P {}
|
|
|
|
var a = X()
|
|
(a~>bar)()
|
|
|
|
// CHECK: [[CHAINED_FUNC:%.*]] = apply {{%.*}}<X, (), ()>({{%.*}}, {{%.*}}) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : P> (@inout τ_0_0, @owned @noescape @callee_guaranteed (@inout τ_0_0) -> @owned @callee_guaranteed (@in τ_0_1) -> @out τ_0_2) -> @owned @callee_guaranteed (@in τ_0_1) -> @out τ_0_2
|
|
// CHECK: [[REABSTRACT:%.*]] = function_ref @_T0ytytIegir_Ieg_TR
|
|
// CHECK: [[CHAINED_FUNC_REABSTRACTED:%.*]] = partial_apply [callee_guaranteed] [[REABSTRACT]]([[CHAINED_FUNC]])
|
|
// CHECK: [[BORROW:%.*]] = begin_borrow [[CHAINED_FUNC_REABSTRACTED]]
|
|
// CHECK: apply [[BORROW]]() : $@callee_guaranteed () -> ()
|