Skip to content

Add missing Sendable conformances#915

Open
kcede wants to merge 1 commit intoswiftlang:mainfrom
kcede:sendable-conformance
Open

Add missing Sendable conformances#915
kcede wants to merge 1 commit intoswiftlang:mainfrom
kcede:sendable-conformance

Conversation

@kcede
Copy link
Copy Markdown

@kcede kcede commented Oct 16, 2025

Description

In the SDK that ships with Xcode, these types are marked as Sendable, which causes source compatibility issues.

Adds missing Sendable conformance to the following types:

  • DispatchQueue.Attributes
  • DispatchQueue.GlobalQueuePriority
  • DispatchQueue.AutoreleaseFrequency
  • DispatchWorkItemFlags
  • DispatchIO.StreamType
  • DispatchIO.CloseFlags
  • DispatchIO.IntervalFlags
  • DispatchData
  • DispatchData.Deallocator
  • DispatchDataIterator

Related issues: #779, #910

Reproduction

import Dispatch

@main
struct swift_dispatch_sendable {
    static func main() async {
        let sendables: [Sendable] = [
            DispatchQueue.Attributes.concurrent,
            DispatchQueue.GlobalQueuePriority.background,
            DispatchQueue.AutoreleaseFrequency.inherit,
            DispatchWorkItemFlags.assignCurrentContext,
            DispatchIO.StreamType.random,
            DispatchIO.CloseFlags.stop,
            DispatchIO.IntervalFlags.strictInterval,
            DispatchData.empty,
            DispatchData.Deallocator.free,
            DispatchData.empty.makeIterator(), // DispatchDataIterator
        ]
    }
}

Expected behavior

The example program should compile without errors.

@trbernstein
Copy link
Copy Markdown

trbernstein commented Mar 8, 2026

This PR is intended to align non-Darwin Dispatch sendability with Darwin behavior.
It appears to address the same class of mismatch discussed in #779, #845, and #847.
The practical effect is that code passing strict concurrency checks on macOS can still fail on Linux due to missing Sendable conformances.

Could a maintainer confirm whether the direction here is acceptable, or whether this should be split into smaller PRs / gated differently?

Edit: While reviewing this again I noticed that DispatchDataIterator currently has an @unchecked Sendable conformance.
That might warrant a closer look, since it could indicate internal mutability or assumptions about thread-safety.

@ktoso
Copy link
Copy Markdown
Contributor

ktoso commented Mar 8, 2026

@swift-ci please smoke test

@ktoso
Copy link
Copy Markdown
Contributor

ktoso commented Mar 8, 2026

I think this is reasonable, thank you

@ktoso
Copy link
Copy Markdown
Contributor

ktoso commented Mar 11, 2026

@swift-ci please smoke test

1 similar comment
@ktoso
Copy link
Copy Markdown
Contributor

ktoso commented Apr 10, 2026

@swift-ci please smoke test

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.

3 participants