You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal/refactor/inline: check caller/callee file Go versions
Inlining a function body declared in a file using a newer Go
release into a caller using an older Go release is liable to
introducing build errors. (This is particularly a risk for
go:fix inline directives introduced by modernizers for newer
language features.)
Ideally the type checker would record, for each piece of syntax,
what minimum Go version it requires, so that we could compute
the dependencies precisely for a given callee function body.
In the meantime, we use the version of the callee file as a whole,
which is quite conservative, and check that the caller file's
version is not older.
Updates golang/go#75726
+ unit test, gopls integration test
Change-Id: I3be25da6fe5eacdb71a340182984a166bcf8d6ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/716560
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Test of caller/callee Go version compatibility check (#75726).
2
+
3
+
-- go.work --
4
+
use .
5
+
use ./b
6
+
7
+
-- go.mod --
8
+
module example.com
9
+
go 1.18
10
+
11
+
-- a/a.go --
12
+
package a
13
+
14
+
import "example.com/b"
15
+
16
+
var _ = b.Add(1, 2) //@ codeaction("Add", "refactor.inline.call", end=")", err=`cannot inline call to b.Add (declared using go1.20) into a file using go1.18`)
0 commit comments