[tools] internal/refactor/inline: built-ins may affect inference

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Dec 3, 2025, 8:26:02 PM (6 hours ago) Dec 3
to Alan Donovan, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Robert Findley, Go LUCI, Markus Kusano, golang-co...@googlegroups.com

Gopher Robot submitted the change

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
Commit-Queue: Alan Donovan <adon...@google.com>
Reviewed-by: Robert Findley <rfin...@google.com>
Auto-Submit: Alan Donovan <adon...@google.com>
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:
  • requirement satisfiedCode-Review: +2 by Robert Findley
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I7bc763cd41a7ec39abf851cb25acd568477b658a
Gerrit-Change-Number: 726480
Gerrit-PatchSet: 5
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-CC: Markus Kusano <kus...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages