Skip to content

Tests: give User/ViewModel stand-ins explicit init signatures#262

Merged
dfed merged 1 commit intomainfrom
claude/fixture-typecheck-fixes
Apr 19, 2026
Merged

Tests: give User/ViewModel stand-ins explicit init signatures#262
dfed merged 1 commit intomainfrom
claude/fixture-typecheck-fixes

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Apr 19, 2026

Summary

  • Add explicit public init() and public init(username: String) to the shared public struct User {} stand-in fixture (used in 23 places across 4 test files)
  • Same treatment for ViewModelA / ViewModelB and the User { id, name } variant in SafeDIToolDOTGenerationTests

Why

Several test fixtures reference User(username: ...), but the bare public struct User {} only synthesizes a memberwise init — so the fixture as written wouldn't compile if fed to swiftc directly. 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 sourceBuild
  • swift test --traits sourceBuild (all 831 tests pass)
  • ./CLI/lint.sh (no formatting changes)

🤖 Generated with Claude Code

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>
@dfed dfed force-pushed the claude/fixture-typecheck-fixes branch from ea82f99 to bc1f150 Compare April 19, 2026 02:32
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
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9fc186a) to head (bc1f150).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #262   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           41        41           
  Lines         6369      6369           
=========================================
  Hits          6369      6369           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfed dfed merged commit 7124b01 into main Apr 19, 2026
17 checks passed
@dfed dfed deleted the claude/fixture-typecheck-fixes branch April 19, 2026 03:10
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