x/tools/internal/refactor/inline: avoid unnecessary interface conversions #68554
Labels
FixPending
Issues that have a fix which has not yet been reviewed or submitted.
NeedsFix
The path to resolution is known, but the work has not been done.
Refactoring
Issues related to refactoring tools
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
This contrived example demonstrates that the source-level inliner (activated through gopls' refactor.inline code action) adds conversions to interface types even when they are not necessary:
Because fmt.Println's arguments are each converted to
any
, the implicit conversion fromdiscard
toio.Writer
is not significant within the body ofg
and could be omitted. By contrast, werefmt.Println
replaced bypanic
, the conversion would not be safe to remove, because in generalpanic(x)
is not equivalent topanic(any(x))
.The inliner should detect, for each interface-typed parameter of the callee, whether all its uses in the callee's body are converted explicitly or implicitly to an interface type, so that the caller-side interface conversion may be safely omitted.
Googlers: see internal issue b/354664998
The text was updated successfully, but these errors were encountered: