Files
swift-mirror/test/SILGen/call_chain_reabstraction.swift
Arnold Schwaighofer 0971d82f70 SILGen: Remaining fixes for @callee_guaranteed closures and enable it
- 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
2017-11-15 19:46:08 -08:00

20 lines
1012 B
Swift

// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
struct A {
func g<U>(_ recur: (A, U) -> U) -> (A, U) -> U {
return { _, x in return x }
}
// CHECK-LABEL: sil hidden @_T024call_chain_reabstraction1AV1f{{[_0-9a-zA-Z]*}}F
// CHECK: [[G:%.*]] = function_ref @_T024call_chain_reabstraction1AV1g{{[_0-9a-zA-Z]*}}F
// CHECK: [[G2:%.*]] = apply [[G]]<A>
// CHECK: [[REABSTRACT_THUNK:%.*]] = function_ref @_T024call_chain_reabstraction1AVA2CIegyir_A3CIegyyd_TR
// CHECK: [[REABSTRACT:%.*]] = partial_apply [callee_guaranteed] [[REABSTRACT_THUNK]]([[G2]])
// CHECK: [[BORROW:%.*]] = begin_borrow [[REABSTRACT]]
// CHECK: apply [[BORROW]]([[SELF:%.*]], [[SELF]])
// CHECK: destroy_value [[REABSTRACT]]
func f() {
let recur: (A, A) -> A = { c, x in x }
let b = g(recur)(self, self)
}
}