Skip to content

Conversation

@atrick
Copy link
Contributor

@atrick atrick commented Jun 4, 2025

main PR: #81992

  • LifetimeDependenceDiagnostics: diagnose indirect closure results.
    Add support for diagnosing calls to closures that return a generic
    non-Escapable result.

    Closures do not yet model lifetime dependencies. The diagnostics have
    a special case for handling nonescaple result with no lifetime
    dependence, but it previously only handled direct results. This fix handles
    cases like the following:

    func callIndirectClosure<T>(f: () -> NE<T>) -> NE<T> {
      f()
    }
    

    Fixes rdar://134318846 ([nonescapable] diagnose function types with nonescapable results)

    (cherry picked from commit 1d09c06)

  • LifetimeDependenceDiagnostics: fix source loc for implicit variables
    Diagnostics on an indirect result ($return_value) did not report a source
    location.

    (cherry picked from commit c030b78)

  • Add unit tests for indirect lifetime dependence.
    (cherry picked from commit b1044c6)

--- CCC ---

Explanation: Add support for diagnosing calls to closures that return a generic
non-Escapable result.

Scope: Limited to -enable-experimental-feature LifetimeDependence

Radar/SR Issue: rdar://134318846 ([nonescapable] diagnose function types with nonescapable results)

main PR: #81992

Risk: Low

Testing: Added unit tests

Reviewer: Meghana Gupta

atrick added 3 commits June 4, 2025 12:03
Add support for diagnosing calls to closures that return a generic
non-Escapable result.

Closures do not yet model lifetime dependencies. The diagnostics have
a special case for handling nonescaple result with no lifetime
dependence, but it previously only handled direct results. This fix handles
cases like the following:

    func callIndirectClosure<T>(f: () -> NE<T>) -> NE<T> {
      f()
    }

Fixes rdar://134318846 ([nonescapable] diagnose function types with nonescapable results)

(cherry picked from commit 1d09c06)
Diagnostics on an indirect result ($return_value) did not report a source
location.

(cherry picked from commit c030b78)
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 4, 2025
@atrick atrick requested a review from a team as a code owner June 4, 2025 19:04
@atrick atrick requested a review from meg-gupta June 4, 2025 19:05
@atrick
Copy link
Contributor Author

atrick commented Jun 4, 2025

@meg-gupta can you review this for 6.2?

@atrick atrick requested a review from tbkka June 4, 2025 19:06
@atrick atrick enabled auto-merge June 4, 2025 19:06
@atrick
Copy link
Contributor Author

atrick commented Jun 4, 2025

@swift-ci test

@atrick atrick merged commit 0d5351b into swiftlang:release/6.2 Jun 5, 2025
5 checks passed
@atrick atrick deleted the 62-fix-lifedep-indirect-closure branch June 5, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks swift 6.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants