Skip to content

Accept fulfillingAdditionalTypes as valid mock return types in macro#215

Merged
dfed merged 1 commit intomainfrom
dfed--mock-additional-type-macro-fix
Apr 5, 2026
Merged

Accept fulfillingAdditionalTypes as valid mock return types in macro#215
dfed merged 1 commit intomainfrom
dfed--mock-additional-type-macro-fix

Conversation

@dfed
Copy link
Copy Markdown
Owner

@dfed dfed commented Apr 5, 2026

Summary

Fixes a bug where the @Instantiable macro rejected mock() methods returning a type from fulfillingAdditionalTypes. The generator already handled this correctly (#213), but the macro validation did not check additionalInstantiables, causing a build error for adopters.

Both the concrete and extension branches now check additionalInstantiables when validating mock return types.

Test plan

  • mockMethodReturningFulfillingAdditionalTypeProducesNoDiagnostic — concrete type with mock() -> MyServiceProtocol
  • extension_mockMethodReturningFulfillingAdditionalTypeProducesNoDiagnostic — extension with mock() -> MyServiceProtocol
  • Full suite (717 tests) passes
  • Lint passes
  • Coverage: all new code fully covered

🤖 Generated with Claude Code

The macro's return type validation now checks additionalInstantiables
in both the concrete and extension branches, matching the generator's
behavior. Previously only the generator accepted additional types,
causing the macro to emit an incorrect return type error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dfed dfed force-pushed the dfed--mock-additional-type-macro-fix branch from 88ad9c3 to 1f8f185 Compare April 5, 2026 14:21
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #215   +/-   ##
=======================================
  Coverage   99.94%   99.94%           
=======================================
  Files          40       40           
  Lines        5648     5652    +4     
=======================================
+ Hits         5645     5649    +4     
  Misses          3        3           
Files with missing lines Coverage Δ
...ources/SafeDIMacros/Macros/InstantiableMacro.swift 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dfed dfed marked this pull request as ready for review April 5, 2026 14:43
@dfed dfed merged commit 1114b38 into main Apr 5, 2026
19 checks passed
@dfed dfed deleted the dfed--mock-additional-type-macro-fix branch April 5, 2026 14:46
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