golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.93k stars 17.66k forks source link

x/tools/internal/refactor/inline,x/tools/gopls: undo variadic elimination when it is safe to do so #63717

Open findleyr opened 1 year ago

findleyr commented 1 year ago

Follow up on this comment on a semi-automated CL: https://go-review.googlesource.com/c/tools/+/537475/1/gopls/internal/lsp/source/rename.go#973

The inliner should undo variadic elimination (packing variadic arguments as []T{...}) when it is safe to do so. As a result of the current logic, the inliner may introduce this redundancy at the callsite.

CC @adonovan

adonovan commented 1 year ago

FWIW, "Safe to do so" means there is exactly one use of the parameter in the callee body and it is the final argument of an ellipsis call f(param...).