]> Cypherpunks repositories - gostls13.git/commit
go/types, cmd/compile/internal/types2: use per-file Go version
authorRuss Cox <rsc@golang.org>
Tue, 14 Mar 2023 01:06:49 +0000 (21:06 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 14 Apr 2023 16:08:31 +0000 (16:08 +0000)
commit804d786a30c664df63ef1e0c95d44772063afae1
tree25514a360478e8361904fbfec0c41f508bfd29df
parent8854be4180fe1fb59c56c645ef8978788eb40170
go/types, cmd/compile/internal/types2: use per-file Go version

For #57001, compilers and others tools will need to understand that
a different Go version can be used in different files in a program,
according to the //go:build lines in those files.

Update go/types and cmd/compile/internal/types2 to track and
use per-file Go versions. The two must be updated together because
of the files in go/types that are generated from files in types2.

The effect of the //go:build go1.N line depends on the Go version
declared in the 'go 1.M' line in go.mod. If N > M, the file gets go1.N
semantics when built with a Go 1.N or later toolchain
(when built with an earlier toolchain the //go:build line will keep
the file from being built at all).
If N < M, then in general we want the file to get go1.N semantics
as well, meaning later features are disabled. However, older Go 1.M
did not apply this kind of downgrade, so for compatibility, N < M
only has an effect when M >= 21, meaning when using semantics
from Go 1.21 or later.

For #59033.

Change-Id: I93cf07e6c687d37bd37a9461dc60cc032bafd01d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476278
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
33 files changed:
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/conversions.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/operand.go
src/cmd/compile/internal/types2/resolver.go
src/cmd/compile/internal/types2/typeset.go
src/cmd/compile/internal/types2/typexpr.go
src/cmd/compile/internal/types2/version.go
src/go/build/deps_test.go
src/go/types/api.go
src/go/types/builtins.go
src/go/types/call.go
src/go/types/check.go
src/go/types/conversions.go
src/go/types/decl.go
src/go/types/expr.go
src/go/types/generate_test.go
src/go/types/instantiate.go
src/go/types/lookup.go
src/go/types/operand.go
src/go/types/resolver.go
src/go/types/typeset.go
src/go/types/typexpr.go
src/go/types/version.go
src/internal/types/testdata/check/go1_19_20.go [new file with mode: 0644]
src/internal/types/testdata/check/go1_20_19.go [new file with mode: 0644]
src/internal/types/testdata/check/go1_21_19.go [new file with mode: 0644]