Skip to content

Remove redundant @unchecked Sendable annotations#201

Open
ianegordon wants to merge 1 commit intoswhitty:mainfrom
ianegordon:ian/unchecked-sendable-group-a
Open

Remove redundant @unchecked Sendable annotations#201
ianegordon wants to merge 1 commit intoswhitty:mainfrom
ianegordon:ian/unchecked-sendable-group-a

Conversation

@ianegordon
Copy link
Copy Markdown
Contributor

Summary

Removes @unchecked Sendable annotations from four sites where the declaration is either redundant (the containing type is already Sendable by other means) or correct with a plain Sendable conformance (all contained values are Sendable).

File:Line Before After
HTTPResponse.swift:40 public enum Payload: @unchecked Sendable public enum Payload: Sendable
WSMessage.swift:34 public enum WSMessage: @unchecked Sendable, Hashable public enum WSMessage: Sendable, Hashable
HTTPConnection.swift:113 actor HTTPRequestSequence<...>: AsyncSequence, AsyncIteratorProtocol, @unchecked Sendable actor HTTPRequestSequence<...>: AsyncSequence, AsyncIteratorProtocol
Logging+OSLog.swift:36 public struct OSLogLogger: Logging, @unchecked Sendable public struct OSLogLogger: Logging

Rationale (primary-source verified)

  • HTTPResponse.Payload: .httpBody(HTTPBodySequence)HTTPBodySequence: Sendable (HTTPBodySequence.swift:35). .webSocket(any WSHandler)WSHandler: Sendable (WSHandler.swift:34).
  • WSMessage: associated values are String, Data, WSCloseCode. WSCloseCode: Sendable (WSCloseCode.swift:34); String / Data are Sendable.
  • HTTPRequestSequence: per SE-0306, "every actor type implicitly conforms to the Sendable protocol." Explicit @unchecked Sendable (or even explicit Sendable) on an actor is redundant.
  • OSLogLogger: os.Logger is declared public struct Logger : @unchecked Swift.Sendable in the Xcode SDK os.swiftmodule interface, and the Logging protocol already requires Sendable (Logging.swift:32) — so both the @unchecked and the explicit Sendable conformance were redundant.

Test plan

  • swift build clean (no warnings, 5.16 s).
  • swift test — 404 tests across 49 suites, all pass (1.13 s total).
  • CI on the upstream repo.

Scope

This is Group A of a broader @unchecked Sendable audit. The remaining 12 sites fall into two categories:

  • Group B — replace with synchronized state (e.g., Mutex-wrapped storage): HTTPBodySequence.Storage, AsyncStream+WSFrame.Iterator, WSFrameValidator.Validator. To be submitted separately.
  • Group C — keep @unchecked with a justifying comment (Transferring, Mutex variants, ConsumingAsyncSequence.SharedBuffer/State, retroactive sockaddr_* conformances). To be submitted separately.

🤖 Generated with Claude Code

All four sites contained only Sendable types:
- HTTPResponse.Payload: both cases hold Sendable values
  (HTTPBodySequence, any WSHandler).
- WSMessage: associated values are Sendable.
- HTTPRequestSequence: actors implicitly conform to Sendable
  per SE-0306.
- OSLogLogger: os.Logger is @unchecked Sendable and the Logging
  protocol already requires Sendable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ianegordon ianegordon marked this pull request as ready for review April 23, 2026 02:14
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.

1 participant