Skip to content

Support multi-arity functions in cljr-change-function-signature - #594

Merged
bbatsov merged 1 commit into
masterfrom
change-signature-multi-arity
Jul 12, 2026
Merged

bbatsov merged 1 commit into
masterfrom
change-signature-multi-arity

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 12, 2026

Copy link
Copy Markdown
Member

Follow-up to the add/remove work: cljr-change-function-signature now handles multi-arity functions instead of erroring on them.

It asks which arity you want to change, then updates only that arity - its definition lambda list and the call sites with a matching argument count. Call sites of other arities are left alone (matched by counting args); variadic and apply/partial sites still go to manual review. To change several arities, run it once per arity.

The single-arity path now flows through the same arity-navigation and arg-count matching (the sole arity always matches), so nothing regresses there.

Validated live against a real refactor-nrepl connection: reordering a chosen arity swapped its lambda list, an internal recursive call, and external calls of that arity, while the other arity and its 1-arg call sites were left untouched. Plus buttercup coverage for the navigation/counting/selection helpers and the multi-arity definition edit, and ecukes coverage for the arity-matched call-site routing.

Design doc (doc/design/change-function-signature.md) updated - this closes out P2.

Building on the tagged add/remove model, the command now handles
multi-arity defns. It prompts for which arity to change (cljr--choose-arity
over cljr--get-function-arities) and edits just that one: the definition's
matching lambda list plus the call sites whose argument count matches.

cljr--goto-arity-lambda-list navigates to the lambda list of the arity
with a given parameter count, handling both bare single-arity lists and
multi-arity clauses. The classifier matches each call site's arg count
(cljr--call-site-arg-count) against the edited arity, leaving calls to
other arities untouched; variadic and apply/partial sites still route to
the manual-intervention buffer.

The single-arity path now flows through the same arity-navigation and
arg-count matching, with the arity always matching. Validated live
against a real refactor-nrepl connection: reordering a chosen arity
swapped its lambda list, an internal recursive call, and external calls
of that arity, while the other arity and its call sites were untouched.
@bbatsov
bbatsov merged commit 7ac3c83 into master Jul 12, 2026
5 of 7 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.

1 participant