Skip to content

Fix Name Override With Inheritance#338

Open
plx wants to merge 2 commits intouber:masterfrom
plx:plx/fix/custom-name-with-protocol-inheritance
Open

Fix Name Override With Inheritance#338
plx wants to merge 2 commits intouber:masterfrom
plx:plx/fix/custom-name-with-protocol-inheritance

Conversation

@plx
Copy link

@plx plx commented Mar 12, 2026

This addresses current limitations mockolo from working as expected when mocking a protocol whose parent protocol that has a custom name override, e.g. this situation:

// In BaseProtocol.swift
/// @mockable(override: name = FakeBase)
protocol BaseProtocol {
    func register()
    var counter: Int { get }
}

// In DerivedProtocol.swift, will be a separate mock invocation
/// @mockable()
protocol DerivedProtocol: BaseProtocol {
    func like()
    func subscribe()
}

In such cases, mockolo currently fails to recognize FakeBase as the parent mock for DerivedProtocol, and thus fails to include the generated implementation from FakeBase in the body of DerivedProtocol.

The changes in this PR correct that.

All existing unit tests still pass, and I added new unit tests covering the behavior above.

The essential part of the change is explicitly maintaining a map from protocol names to the names of their mocks; it also addresses a few other places where the code implicitly only worked with the default naming pattern.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants