aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/api.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-02-03 14:56:13 -0800
committerRobert Griesemer <gri@golang.org>2021-02-04 22:20:33 +0000
commit1ff2fdaaf189e0d7ec73bdbff72558363239f48b (patch)
tree42512eabd1fa092e171cc296c2d1cfad86ec6220 /src/cmd/compile/internal/types2/api.go
parent370e9f58432c51bf3d95308cdc7109e25cc141f6 (diff)
downloadgo-1ff2fdaaf189e0d7ec73bdbff72558363239f48b.tar.gz
go-1ff2fdaaf189e0d7ec73bdbff72558363239f48b.zip
[dev.typeparams] cmd/compile/internal/types2: add support for language version checking
Add the Config.Lang field which may be set to a Go version string, such as "go1.12". This is a string rather than explicit semantic version numbers (such as {1, 12}) for API robustness; a string is more flexible should we need more or different information. Add -lang flag to types2 package for use with (manual) testing when running "go test -run Check$ -lang=... -files=...". While changing flags, look for comma-separated (rather than space- separated) files when providing the -file flag. Check that numeric constant literals, signed shift counts are accepted according to the selected language version. Type alias declarations and overlapping embedded interfaces are not yet checked. Updates #31793. Change-Id: I9ff238ed38a88f377eb2267dc3e8816b89a40635 Reviewed-on: https://go-review.googlesource.com/c/go/+/289509 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/api.go')
-rw-r--r--src/cmd/compile/internal/types2/api.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/api.go b/src/cmd/compile/internal/types2/api.go
index b29c0802ed..30f0430ff1 100644
--- a/src/cmd/compile/internal/types2/api.go
+++ b/src/cmd/compile/internal/types2/api.go
@@ -99,6 +99,13 @@ type ImporterFrom interface {
// A Config specifies the configuration for type checking.
// The zero value for Config is a ready-to-use default configuration.
type Config struct {
+ // GoVersion describes the accepted Go language version. The string
+ // must follow the format "go%d.%d" (e.g. "go1.12") or ist must be
+ // empty; an empty string indicates the latest language version.
+ // If the format is invalid, invoking the type checker will cause a
+ // panic.
+ GoVersion string
+
// If IgnoreFuncBodies is set, function bodies are not
// type-checked.
IgnoreFuncBodies bool