Skip to content

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Sep 24, 2025

  • Explanation:

    Fixes a few situations where Sendable checking was performed on conversions that don't require it.

    • Fixes @Sendable closures not inferring nonisolated(nonsending)

      If there are no explicit concurrency attributes, isolated parameters, or captures associated with the closure it should infer nonisolated(nonsending) for the parent conversion injected by the solver (this conversion is injected because the solver cannot check captures to elide it).

    • Moves function conversion check from pre-walk to post-walk. This makes sure that sub-expressions have their isolation computed (especially imported for closures) before checking is performed. The checking itself is idempotent.

    • Skips checking when function conversion is used to erase @Sendable from nonisolated(nonsending) function type, this doesn't require a thunk and so there is no possibility of isolation boundary crossing.

    • Detects situations when function conversion is used to apply nonisolated(nonsending) attribute to interface type of a declaration.

  • Resolves: rdar://157663660

  • Main Branch PR: [Concurrency] Fix @Sendable closures not inferring `nonisolated(non… #84117, [Concurrency] Prevent some extraneous function conversion sendability checking  #84409

  • Risk: Low. This is a narrow fix that prevents some checks from happening and results in more code accepted by the compiler.

  • Reviewed By: @hborla

  • Testing: Added new test-cases to the suite.

@xedin xedin requested a review from a team as a code owner September 24, 2025 19:02
@xedin xedin added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Sep 24, 2025
…sending)`

If there are no explicit concurrency attributes, isolated parameters,
or captures associated with the closure it should infer `nonisolated(nonsending)`
for the parent conversion injected by the solver (this conversion is injected
because the solver cannot check captures to elide it).

The change pushes `isIsolationInferenceBoundaryClosure` check down
with added benefit of getting preconcurrency context from the parent.

(cherry picked from commit 3ae34e8)
…have been checked

Explicit closure expressions gets their isolation inferred during
actor isolation checking, if they appear as a sub-expression to
a function conversion we need to delay function checking until
the closure was processed. It shouldn't matter for other cases.

(cherry picked from commit 61fbaa7)
…ndable` from `nonisolated(nonsending)` function type

The isolation doesn't change in this cause and making function type
non-Sendable means that it woun't be able to leave the current concurrency
domain and the compiler won't generate a thunk.

(cherry picked from commit 40c9674)
…nonisolated(nonsending)`

`nonisolated(nonsending)` is not presented in interface types
which means that references to declarations that have this attribute
require a function conversion to apply it. Function conversion
checking should detect that and avoid sendability checking for
situations like that but there is really no conversion there.

(cherry picked from commit ce33100)
@xedin
Copy link
Contributor Author

xedin commented Sep 25, 2025

@swift-ci please test

@xedin xedin merged commit 9ffb303 into swiftlang:release/6.2 Sep 26, 2025
5 checks passed
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