Skip to content

@Injected Properties Used in Sendable Situations Throw Concurrency Errors in Swift 6.3 (Xcode 26.4) #354

@Christopher-A

Description

@Christopher-A

Given this example, with StateMachine being Sendable,

@Injected(\.applicationStateMachine) var stateMachine

Task {
    await stateMachine.processEvent(event)
}

We get compiler errors (oddly only when building for device).
Task-isolated '_stateMachine' is captured by a nonisolated closure. nonisolated uses in closure may race against later nonisolated uses

However, we have found the following does not produce the error:

let stateMachine = Container.shared.applicationStateMachine.resolve()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions