Skip to content

LifetimeDependenceDiagnostics: diagnose indirect closure results. #81992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 4, 2025

  • 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)

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

  • Add unit tests for indirect lifetime dependence.

atrick added 3 commits June 4, 2025 11:40
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)
Diagnostics on an indirect result ($return_value) did not report a source
location.
@atrick atrick requested a review from eeckstein as a code owner June 4, 2025 18:58
@atrick atrick requested a review from meg-gupta June 4, 2025 18:59
@atrick
Copy link
Contributor Author

atrick commented Jun 4, 2025

@swift-ci test

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atrick
Copy link
Contributor Author

atrick commented Jun 5, 2025

@swift-ci smoke test macOS

@atrick atrick merged commit 765204d into swiftlang:main Jun 5, 2025
4 of 5 checks passed
@atrick atrick deleted the 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants