Skip to content

Matchers for Sendable mocks, and deprecate users' Matchable conformances - #71

Merged
nmcc24 merged 4 commits into
masterfrom
sendable-matchers
Nov 13, 2026
Merged

nmcc24 merged 4 commits into
masterfrom
sendable-matchers

Conversation

@nmcc24

@nmcc24 nmcc24 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

The 3.0.0-beta.3 matcher work. The stubs of Sendable and actor mocks can be called from any task, so they now take only matchers that are safe there.

Changelog

  • b23affa Add SendableMatcher and deprecate users' Matchable conformances. SendableMatcher keeps a @Sendable closure. Each matcher function returns one when the values it keeps are Sendable, and a ParameterMatcher otherwise. Matchers that keep nothing (any(), anyInt(), anyString(), isNil(), notNil(), anyClosure(), hasLength), and sameInstance(as:) for any class, always return a SendableMatcher. or, and and not keep the kind, and an ArgumentCaptor of Sendable values captures with one. Matchable and OptionalMatchable become _Matchable and _OptionalMatchable, with _Sendable… refinements, and the old names are deprecated aliases: pass equal(to:) instead of conforming your own types. A property stub's set takes the Sendable kind for a Sendable mock.
  • 2df4cb8 Make Sendable mocks' stubs take only Sendable matchers. The generated stubbing proxies of Sendable and actor mocks take _SendableMatchable arguments and wrap each with a key path, which captures no metatype of a generic method. Verification proxies, and every other mock, take either kind. New fixture 31 covers every matcher kind; fixture 32 must fail to compile (a Sendable mock given a non-Sendable value) and is listed as an expected failure. Snapshots re-recorded.
  • 0464934 Document matchers for Sendable mocks and the Matchable deprecation. New "Matchers for Sendable mocks" section in Matching.md (including nonisolated Equatable for projects that isolate to the main actor by default), migration notes, curation, and the CHANGELOG's Unreleased section.
  • 239dca0 Roadmap: beta.3 matchers, and hiding Matchable in 4.0. The 4.0 item renames the protocols back to Matchable under @_spi(CuckooGenerated) and removes the aliases (a hard break).

Verified

  • Linux, Swift 6.2, 6.3 and 6.4: swift test (543 tests, 13 known issues, 0 warnings; 6.2 also with every upcoming feature on) and the fixture matrix with features off, on, and as a new Xcode 26 project.
  • macOS, Xcode 27.2 (Swift 6.4.2): swift test (543 tests, 13 known issues, 0 warnings) and the CuckooTests scheme on the iOS simulator.
  • scripts/build-docs.sh on Swift 6.3: no warnings.

nmcc24 and others added 4 commits November 13, 2026 11:36
Each matcher function returns a SendableMatcher, whose closure is @sendable,
when the values it keeps are Sendable, and a ParameterMatcher otherwise.
Matchers that keep nothing, and sameInstance(as:), are always Sendable.
or, and and not keep the kind.

Matchable and OptionalMatchable become _Matchable and _OptionalMatchable,
with _Sendable refinements, and the old names are deprecated aliases:
pass equal(to:) instead of conforming your own types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stubbing proxies of Sendable and actor mocks take _SendableMatchable
arguments and wrap each with a key path, which captures no metatype of a
generic method. Verification proxies and other mocks take either kind.
Fixture 31 covers every matcher kind; fixture 32 must fail to compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nmcc24
nmcc24 merged commit 8df4849 into master Nov 13, 2026
16 checks passed
@nmcc24
nmcc24 deleted the sendable-matchers branch November 13, 2026 12:05
@nmcc24 nmcc24 mentioned this pull request Nov 13, 2026
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