diff --git a/include/swift/SIL/SILBridgingImpl.h b/include/swift/SIL/SILBridgingImpl.h index d0aa56029608c..ce7f353ac620e 100644 --- a/include/swift/SIL/SILBridgingImpl.h +++ b/include/swift/SIL/SILBridgingImpl.h @@ -1362,11 +1362,11 @@ BridgedNullableVarDecl BridgedInstruction::AllocBox_getDecl() const { } BridgedNullableVarDecl BridgedInstruction::GlobalAddr_getDecl() const { - return {getAs()->getDecl()}; + return {getAs()->getReferencedGlobal()->getDecl()}; } BridgedNullableVarDecl BridgedInstruction::RefElementAddr_getDecl() const { - return {getAs()->getDecl()}; + return {getAs()->getField()}; } OptionalBridgedSILDebugVariable diff --git a/test/SILOptimizer/lifetime_dependence/lifetime_dependence_borrow_fail.swift b/test/SILOptimizer/lifetime_dependence/lifetime_dependence_borrow_fail.swift index d05f469194ada..03387dea2b3d5 100644 --- a/test/SILOptimizer/lifetime_dependence/lifetime_dependence_borrow_fail.swift +++ b/test/SILOptimizer/lifetime_dependence/lifetime_dependence_borrow_fail.swift @@ -64,3 +64,9 @@ func bv_incorrect_annotation2(_ w1: borrowing Wrapper, _ w2: borrowing Wrapper) return w1.bv // expected-note @-1{{it depends on the lifetime of argument 'w1'}} } // expected-note @-1{{this use causes the lifetime-dependent value to escape}} +let ptr = UnsafeRawPointer(bitPattern: 1)! +let nc = NC(ptr, 0) // expected-error {{lifetime-dependent variable 'nc' escapes its scope}} + +func bv_global(dummy: BV) -> BV { + nc.getBV() +} // expected-note {{this use causes the lifetime-dependent value to escape}}