Tests: give User/ViewModel stand-ins explicit init signatures#262
Merged
Conversation
Several fixtures invoke `User(username:)` against a bare
`public struct User {}` stand-in, which has no such initializer. Add
`public init(username: String) {}` to the 10 affected fixtures so the
fixture compiles as written. Two id/name User fixtures call `User()` but
declared stored properties without defaults — give the properties
defaults so the synthesized empty init covers `User()`.
Targeted change: only the fixtures that need help are touched. Bare
`public struct User {}` works fine for `User()` callers via Swift's
synthesized init, so those fixtures stay unchanged. No production or
generator output changes.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ea82f99 to
bc1f150
Compare
dfed
added a commit
that referenced
this pull request
Apr 19, 2026
Apply the minimal stand-in pattern from PR #262: only declare the initializer signatures fixtures actually call. Bare `public struct T {}` synthesizes an internal init that's accessible to other fixture files in the same compile unit, so it satisfies `T()` callers without explicit inits. Where a fixture invokes `T(username:)`, declare exactly that single initializer. Inline single-line `struct { init }` declarations are split to multi-line form. For ViewModelA/B in mock_disambiguatedDefaultParamsFromDifferentChildrenDoNotCollideAtRoot, the synthesized internal init can't be referenced from a public default argument value, so explicit `public init() {}` stays — but moves to its own line. For id/name User stand-ins, default values on the stored properties suffice; the User() callers don't need an explicit init. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 6369 6369
=========================================
Hits 6369 6369 🚀 New features to boost your workflow:
|
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.
Summary
public init()andpublic init(username: String)to the sharedpublic struct User {}stand-in fixture (used in 23 places across 4 test files)ViewModelA/ViewModelBand theUser { id, name }variant inSafeDIToolDOTGenerationTestsWhy
Several test fixtures reference
User(username: ...), but the barepublic struct User {}only synthesizes a memberwise init — so the fixture as written wouldn't compile if fed toswiftcdirectly. The tests pass today because fixture source isn't actually compiled, but the divergence from real Swift gets in the way of any future tooling that wants to typecheck fixtures end-to-end.No production code or generator output changes — only the fixture stand-ins.
Test plan
swift build --traits sourceBuildswift test --traits sourceBuild(all 831 tests pass)./CLI/lint.sh(no formatting changes)🤖 Generated with Claude Code