Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dfed/SafeDI
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.0-alpha-3
Choose a base ref
...
head repository: dfed/SafeDI
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.0.0-alpha-4
Choose a head ref
  • 3 commits
  • 13 files changed
  • 2 contributors

Commits on Apr 5, 2026

  1. Configuration menu
    Copy the full SHA
    d43c295 View commit details
    Browse the repository at this point in the history
  2. Allow mock() to return fulfillingAdditionalTypes with return-type-awa…

    …re dispatch (#213)
    
    ## Summary
    - Mock return type validation now accepts types listed in
    `fulfillingAdditionalTypes` in addition to the declaring type
    - On concrete types: `Self`, the type name, or any additional type
    - On extensions: the extended type or any additional type
    - The generator checks `mockReturnType` against the property type before
    deciding to call `.mock` vs `init`/`instantiate` — a mock returning
    `MyServiceProtocol` is used when the parent's property is
    `MyServiceProtocol`, but falls through to `init`/`instantiate` when the
    parent needs the concrete `MyService`
    - Adds `mockReturnType: TypeDescription?` to `Instantiable` and
    `mockReturnTypeIsCompatible(withPropertyType:)` to encapsulate the
    dispatch logic
    - Updates the manual to document additional type return rules
    
    ## Test plan
    - [x] `mockMethodReturningAdditionalTypeProducesNoDiagnostic` — concrete
    type returning a protocol from `fulfillingAdditionalTypes` (macro
    validation)
    - [x] `extension_mockMethodReturningAdditionalTypeProducesNoDiagnostic`
    — extension returning a protocol from `fulfillingAdditionalTypes` (macro
    validation)
    - [x] `mock_userMockReturningAdditionalTypeUsedForProtocolProperty` —
    concrete: generator uses `.mock` when property is the protocol type
    - [x] `mock_userMockReturningAdditionalTypeNotUsedForConcreteProperty` —
    concrete: generator falls through to `init` when property is the
    concrete type
    - [x]
    `mock_extensionUserMockReturningAdditionalTypeUsedForProtocolProperty` —
    extension: generator uses `.mock` when property is the protocol type
    - [x]
    `mock_extensionUserMockReturningAdditionalTypeNotUsedForConcreteProperty`
    — extension: generator falls through to `.instantiate` when property is
    the concrete type
    - [x] All 709 tests pass
    - [x] Lint passes
    - [x] Coverage: all new code fully covered
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    dfed and claude authored Apr 5, 2026
    Configuration menu
    Copy the full SHA
    6dd6df9 View commit details
    Browse the repository at this point in the history
  3. Error when generateMock: true conflicts with user-defined mock method (

    …#214)
    
    ## Summary
    - When an `@Instantiable` type has both `generateMock: true` and a
    hand-written `mock()` method, the macro now emits a compile-time error
    with a fix-it to remove `generateMock: true`.
    - Previously this was silently handled at the tool level (skipping
    generation). Now it's caught early with a clear diagnostic.
    - Applies to both concrete type declarations and extension-based
    `@Instantiable` types.
    
    ## Test plan
    - [x]
    `producesDiagnostic_whenGenerateMockIsTrueAndUserDefinedMockExists` —
    single-argument attribute, fix-it removes entire argument clause
    - [x]
    `producesDiagnostic_whenGenerateMockIsTrueAndUserDefinedMockExistsWithOtherArguments`
    — multi-argument attribute, fix-it removes only `generateMock: true`
    - [x]
    `mockMethodConflictsWithGenerateMock_description_mentionsBothGenerateMockAndMockMethod`
    - [x]
    `mockMethodConflictsWithGenerateMock_fixIt_mentionsRemovingGenerateMock`
    - [x] Full test suite passes (709 tests)
    - [x] SwiftFormat clean
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    dfed and claude authored Apr 5, 2026
    Configuration menu
    Copy the full SHA
    a1c24df View commit details
    Browse the repository at this point in the history
Loading