Skip to content

Resolve module-qualified inherited types - #362

Merged
sidepelican merged 2 commits into
uber:masterfrom
farkasseb:fix/module-qualified-inheritance
Nov 4, 2026
Merged

sidepelican merged 2 commits into
uber:masterfrom
farkasseb:fix/module-qualified-inheritance

Conversation

@farkasseb

Copy link
Copy Markdown
Contributor
// Module Accounts
public protocol SessionManaging {
    func signOut()
}

// App
import Accounts

/// @mockable
protocol AccountService: Accounts.SessionManaging {}

The generated AccountServiceMock had no signOut(), even when the parent's source was scanned, so it failed to conform.

The inheritance parser now uses the last component of a qualified type name for lookup, matching the existing protocol map.

The lookup also skips names already on the current inheritance path. This prevents self-recursion that resolving qualified names would otherwise introduce for declarations such as protocol P: OtherModule.P.

Tests:

  • testModuleQualifiedInheritance: a compiled fixture checks that the mock includes both inherited and local methods.
  • testModuleQualifiedInheritanceWithSameName: checks that protocol P: OtherModule.P preserves the previous generated output without recursing.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sidepelican sidepelican left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix.

mockolo’s current lookup logic does not support qualified names, so this change alone will not address every case, and I expect some edge cases will remain.

That said, given the existing limitations, I think this is a practical improvement and would like to accept it as an incremental step.

Co-authored-by: Iceman <side.junktown@gmail.com>
@sidepelican
sidepelican merged commit 62fed69 into uber:master Nov 4, 2026
11 checks passed
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