mirror of
https://github.com/apple/swift.git
synced 2026-10-06 12:37:28 +02:00
In LifetimeDependenceDiagnostics, disable diagnostics of function arguments that
have a noescape function type. Diagosing noescape function-type arguments is
meant to be handled by a separate pass, DiagnoseInvalidEscapingCaptures. In some
distant future, we could consider merging these diagnostics. For now, they
should be independent.
This fixes a bug introduced with:
commit e3d55f64c2
Date: Wed Apr 29 10:37:32 2026 +0100
Lifetimes: Treat noescape function types as ~Escapable
After that change, lifetime diagnostics inadvertantly kicked on for noescape
function-type arg. The diagnostic would then fail when importing ObjC API with
an optional noescape function such as:
+ (instancetype)takeNoEscapeBlock:(void(NS_NOESCAPE ^)(void))block;
// error: lifetime-dependent variable 'block' escapes its scope)
Here the compiler generates a thunk to unwrap the optional and generates a
mark_dependence on the Optional's inner value.
Fixes rdar://177381648 - error: lifetime-dependent variable escapes its scope
14 lines
413 B
Swift
14 lines
413 B
Swift
// RUN: %target-swift-frontend -primary-file %s -parse-as-library -emit-sil \
|
|
// RUN: -import-objc-header "%S/Inputs/verify_diagnostics_objc_header.h" \
|
|
// RUN: -o /dev/null \
|
|
// RUN: -verify \
|
|
// RUN: -verify-additional-file "%S/Inputs/verify_diagnostics_objc_header.h" \
|
|
// RUN: -sil-verify-all \
|
|
// RUN: -module-name test
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
func test() {
|
|
let _ = TakeNoEscapeBlock { }
|
|
}
|