Gopher Robot submitted the change![Open in Gerrit]()
Change information
Commit message:
internal/refactor/inline: built-ins may affect inference
This change fixes a bug that caused argument conversions to
be neglected when inlining calls to functions whose body
calls certain built-ins such as new:
func f(x int64) *int64 { return new(x) }
var _ *int64 = f(42) // => new(42), should be new(int64(42))
The solution is to consider built-in functions as well as
ordinary non-method functions when computing whether the
argument may affect type inference.
This results in a slight style regression when dealing with
complex numbers, but they are rare.
+ test
Fixes golang/go#76287
Change-Id: I7bc763cd41a7ec39abf851cb25acd568477b658a
Files:
- M internal/refactor/inline/callee.go
- M internal/refactor/inline/falcon_test.go
- M internal/refactor/inline/inline_test.go
- A internal/refactor/inline/testdata/newexpr.txtar
Change size: M
Delta: 4 files changed, 95 insertions(+), 3 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Robert Findley
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I7bc763cd41a7ec39abf851cb25acd568477b658a
Gerrit-Change-Number: 726480
Gerrit-PatchSet: 5