mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
23 lines
484 B
Swift
23 lines
484 B
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
|
class A {
|
|
init(handler: (() -> ())) { }
|
|
}
|
|
|
|
class B { }
|
|
|
|
// CHECK: define {{.*}} @"$s11WeakCapture8functionyyF"()
|
|
func function() {
|
|
let b = B()
|
|
|
|
// Ensure that the local b and its weak copy are distinct local variables.
|
|
// CHECK: #dbg_{{.*}}(ptr [[B:.*]],
|
|
// CHECK: #dbg_{{.*}}(ptr
|
|
// CHECK-NOT: [[B]]
|
|
// CHECK: call
|
|
A(handler: { [weak b] in
|
|
if b != nil { }
|
|
})
|
|
}
|
|
|
|
function()
|