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