Swift Concurrency inappropriately flags main-actor bound code in non-Sendable closure as not running on main actor #75003
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
concurrency
Feature: umbrella label for concurrency language features
Description
@MainActor
-bound code that declares a function inside a non-escaping, non-Sendable anonymous closure fails to compile if the innermost function interacts with the@MainActor
unless the innermost function is declared@MainActor
.According to #72382 (comment), a non-sendable closure can never leave the isolation domain it's formed in, and therefore if a non-sendable closure is declared in a
@MainActor
-bound context, the non-sendable closure should also be@MainActor
-bound.This issue makes utilizing anonymous closures in code-gen in code where strict concurrency code is turned on problematic.
Reproduction
Expected behavior
The code compiles
Environment
Reproduces on both:
Additional information
No response
The text was updated successfully, but these errors were encountered: