Files
swift-mirror/test/SILOptimizer/moveonly_nonescaping_closures_function_conversion.swift
Joe Groff 8f30a0097a MoveOnlyChecker: Look through convert_function of nonescaping closures.
Like a nested partial_apply reabstraction, but without the thunk, these change
the representation of the function but can't escape it without breaking the
nonescaping closure promotion. rdar://111060678
2023-06-20 18:20:45 -07:00

26 lines
564 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
// rdar://111060678
protocol P {
func doStuff() throws
}
struct A: ~Copyable {
let b = B()
consuming func f(_ p: some P) throws -> B {
// Passing the closure here undergoes a SIL-level function conversion
// from the concrete type `() -> Void` to `<T> () throws -> T`.
try b.takeClosure {
try b.takeP(p)
}
return B()
}
}
struct B {
func takeClosure<T>(_ f: () throws -> T) throws -> T { try f() }
func takeP(_: some P) throws {}
}