Repository navigation
Pass inout arguments with & in template func mocks - #364
Merged
Merged
Conversation
With --use-template-func, the handler call in the generated mock passed inout arguments without &, so mocks for protocols with inout parameters failed to compile. The non-template path already adds &. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
sagarpant
marked this pull request as ready for review
October 25, 2026 05:14
sidepelican
approved these changes
Nov 4, 2026
sidepelican
left a comment
Contributor
There was a problem hiding this comment.
I'm surprised that the --use-template-func feature is being used, but there doesn't seem to be any problem with this change itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
--use-template-func, the generated mock passesinoutarguments to the handler without&, so mocks for protocols withinoutparameters don't compile.Before:
After:
The non-template path already handles this (
ClosureTemplate), so only--use-template-funcwas affected.Fix
In
MethodTemplate.renderParamValues, emit&+ the argument name whenarg.type.isInOut, matching the non-template path.Tests
The existing
testInoutParamsruns withoutuseTemplateFunc, and the onlyuseTemplateFunc: truetest (testMockFuncs) usessimpleFuncs, which has noinoutparameters, so the combination wasn't covered. This addstestInoutParamsMockFuncs, which runs the existinginoutParamsfixture withuseTemplateFunc: true.swift testpasses locally on macOS (158 XCTests + the Swift Testing suite).🤖 Generated with Claude Code