mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Although nonescaping closures are representationally trivial pointers to their on-stack context, it is useful to model them as borrowing their captures, which allows for checking correct use of move-only values across the closure, and lets us model the lifetime dependence between a closure and its captures without an ad-hoc web of `mark_dependence` instructions. During ownership elimination, We eliminate copy/destroy_value instructions and end the partial_apply's lifetime with an explicit dealloc_stack as before, for compatibility with existing IRGen and non-OSSA aware passes.
13 lines
262 B
Swift
13 lines
262 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
|
|
|
|
func foo<T>(_ a: T) -> Int {
|
|
return 0
|
|
}
|
|
|
|
func foo(_ a: (Int) -> (Int)) -> Int {
|
|
return 42
|
|
}
|
|
|
|
// CHECK: function_ref @$s12rdar351421213fooyS3iXEF :
|
|
let _ = foo({ (a: Int) -> Int in a + 1 })
|