Skip to content

Fix same-type where constraint generating non-generic type parameter in Swift 6#348

Merged
sidepelican merged 7 commits into
masterfrom
copilot/fix-mock-generation-swift-6
May 2, 2026
Merged

Fix same-type where constraint generating non-generic type parameter in Swift 6#348
sidepelican merged 7 commits into
masterfrom
copilot/fix-mock-generation-swift-6

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

When a protocol uses a same-type where constraint to specialize an inherited associated type (e.g. where Value == Int), mockolo incorrectly emits the associated type as a generic parameter on the mock class — a warning in Swift 5 and an error in Swift 6 language mode.

Before:

public protocol NarrowFoo: Foo where Value == Int {}

// Generated (broken in Swift 6):
public final class NarrowFooMock<Value>: NarrowFoo where Value == Int { ... }
// error: same-type requirement makes generic parameter 'Value' non-generic

After:

// Generated (correct):
public class NarrowFooMock: NarrowFoo { ... }

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 1, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sidepelican
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 4 commits May 1, 2026 06:06
…t 6 mock generation

Agent-Logs-Url: https://github.com/uber/mockolo/sessions/edbc2e01-7112-4085-a7dc-f879e4df0667

Co-authored-by: sidepelican <19257572+sidepelican@users.noreply.github.com>
Agent-Logs-Url: https://github.com/uber/mockolo/sessions/edbc2e01-7112-4085-a7dc-f879e4df0667

Co-authored-by: sidepelican <19257572+sidepelican@users.noreply.github.com>
Agent-Logs-Url: https://github.com/uber/mockolo/sessions/edbc2e01-7112-4085-a7dc-f879e4df0667

Co-authored-by: sidepelican <19257572+sidepelican@users.noreply.github.com>
Agent-Logs-Url: https://github.com/uber/mockolo/sessions/edbc2e01-7112-4085-a7dc-f879e4df0667

Co-authored-by: sidepelican <19257572+sidepelican@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix generated mock for NarrowFoo in Swift 6 language mode Fix same-type where constraint generating non-generic type parameter in Swift 6 May 1, 2026
Copilot AI requested a review from sidepelican May 1, 2026 06:11
@sidepelican sidepelican marked this pull request as ready for review May 1, 2026 06:59
@sidepelican sidepelican requested a review from fummicc1 May 1, 2026 07:05
Copy link
Copy Markdown
Collaborator

@fummicc1 fummicc1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@sidepelican sidepelican merged commit f0f2444 into master May 2, 2026
7 of 8 checks passed
@sidepelican sidepelican deleted the copilot/fix-mock-generation-swift-6 branch May 2, 2026 02:22
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.

Generated mock for a specialized protocol is incorrect in Swift 6 language mode

4 participants