Repository navigation
Matchers for Sendable mocks, and deprecate users' Matchable conformances - #71
Merged
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 3.0.0-beta.3 matcher work. The stubs of
Sendableand actor mocks can be called from any task, so they now take only matchers that are safe there.Changelog
SendableMatcherkeeps a@Sendableclosure. Each matcher function returns one when the values it keeps areSendable, and aParameterMatcherotherwise. Matchers that keep nothing (any(),anyInt(),anyString(),isNil(),notNil(),anyClosure(),hasLength), andsameInstance(as:)for any class, always return aSendableMatcher.or,andandnotkeep the kind, and anArgumentCaptorofSendablevalues captures with one.MatchableandOptionalMatchablebecome_Matchableand_OptionalMatchable, with_Sendable…refinements, and the old names are deprecated aliases: passequal(to:)instead of conforming your own types. A property stub'ssettakes theSendablekind for aSendablemock.Sendableand actor mocks take_SendableMatchablearguments 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 (aSendablemock given a non-Sendablevalue) and is listed as an expected failure. Snapshots re-recorded.Matching.md(includingnonisolated Equatablefor projects that isolate to the main actor by default), migration notes, curation, and the CHANGELOG's Unreleased section.Matchableunder@_spi(CuckooGenerated)and removes the aliases (a hard break).Verified
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.swift test(543 tests, 13 known issues, 0 warnings) and theCuckooTestsscheme on the iOS simulator.scripts/build-docs.shon Swift 6.3: no warnings.