Skip to content

[6.2] LifetimeDependenceScopeFixup: handle yielded value copies. #82050

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 2 commits into from
Jun 10, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 6, 2025

  • LifetimeDependenceScopeFixup: handle yielded value copies.
    When extending an access scope over a coroutines, instead of simply
    considering the lifetime of the coroutine scope, recurse through all
    uses of yielded values. They may be copyable, non-Escapable values
    that depend on the coroutine operand.

    Fixes rdar://152693622 (Extend coroutines over copied yields)

    (cherry picked from commit 227f802)

--- CCC ---

Explanation: When a coroutine yields a non-Escapable type, like Span, the container's access scope must be extended across all copies of that Span.

Scope: May fix miscompiles in Span-like property APIs imlemented using coroutines. None exist in the standard library today, so this appears limited to -enable-experimental-feature LifetimeDependence.

Radar/SR Issue: rdar://152693622 (Extend coroutines over copied yields)

main PR: #82049

Risk: Low

Testing: Added a unit test

Reviewer: Meghana Gupta

atrick added 2 commits June 5, 2025 20:24
When extending an access scope over a coroutines, instead of simply
considering the lifetime of the coroutine scope, recurse through all
uses of yielded values. They may be copyable, non-Escapable values
that depend on the coroutine operand.

Fixes rdar://152693622 (Extend coroutines over copied yields)

(cherry picked from commit 227f802)
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 6, 2025
@atrick atrick requested a review from a team as a code owner June 6, 2025 03:24
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 6, 2025
@atrick
Copy link
Contributor Author

atrick commented Jun 6, 2025

@swift-ci test

@atrick atrick requested a review from meg-gupta June 6, 2025 03:35
@atrick atrick enabled auto-merge June 6, 2025 03:45
@atrick
Copy link
Contributor Author

atrick commented Jun 10, 2025

@swift-ci test

@atrick atrick merged commit 302c563 into swiftlang:release/6.2 Jun 10, 2025
5 checks passed
@atrick atrick deleted the 62-lifedep-fix-yield branch June 10, 2025 17:07
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