Files
swift-mirror/SwiftCompilerSources/Sources/Optimizer/FunctionPasses
Andrew Trick a133bab977 Fix LifetimeDependenceDiagnostics - disable noescape function args
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
2026-05-28 16:21:43 -07:00
..