]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: unexport the GoVersion configuration option for Go 1.17
authorRob Findley <rfindley@google.com>
Fri, 28 May 2021 15:58:05 +0000 (11:58 -0400)
committerRobert Findley <rfindley@google.com>
Sun, 30 May 2021 02:37:38 +0000 (02:37 +0000)
The GoVersion field was added to types.Config as part of the work on
type parameters. Specifically, it was added to be consistent with
cmd/compile/internal/types2, which requires such an option.

This configuration option is useful, but is also non-trivial and did not
go through the proposal process. Unexport it for Go 1.17; we can create
a proposal to export it for Go 1.18.

Fixes #46296

Change-Id: Id82d8a7096887dcfc404c4d6d8da9c761b316609
Reviewed-on: https://go-review.googlesource.com/c/go/+/323430
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/api.go
src/go/types/check.go
src/go/types/check_test.go
src/go/types/stdlib_test.go
src/go/types/types_test.go

index ed62a785d6c9c12ba9021348c7dc150b821c92f2..8c0d9d22bf26aa671f6bf65c7676dc2bf806a78a 100644 (file)
@@ -101,12 +101,12 @@ 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
+       // goVersion describes the accepted Go language version. The string
        // must follow the format "go%d.%d" (e.g. "go1.12") or it 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
+       goVersion string
 
        // If IgnoreFuncBodies is set, function bodies are not
        // type-checked.
index 25ea4906be35f52f38909b1d458c5416be8c2b0d..a923c3c612124f21f6baa59cec4967ee5084a271 100644 (file)
@@ -179,9 +179,9 @@ func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Ch
                info = new(Info)
        }
 
-       version, err := parseGoVersion(conf.GoVersion)
+       version, err := parseGoVersion(conf.goVersion)
        if err != nil {
-               panic(fmt.Sprintf("invalid Go version %q (%v)", conf.GoVersion, err))
+               panic(fmt.Sprintf("invalid Go version %q (%v)", conf.goVersion, err))
        }
 
        return &Checker{
index c5dc93eade6b7b010558350221313a86d56e7fbe..9c71277264b85200daf308896e7a60735f848788 100644 (file)
@@ -240,7 +240,7 @@ func checkFiles(t *testing.T, sizes Sizes, goVersion string, filenames []string,
        // typecheck and collect typechecker errors
        var conf Config
        conf.Sizes = sizes
-       conf.GoVersion = goVersion
+       SetGoVersion(&conf, goVersion)
 
        // special case for importC.src
        if len(filenames) == 1 {
index 3dea8dcf1ed731944dcd10d983e114e83d6ff31b..503d0a6f445afc8e41d45251c8c8fdcbc0d8dc71 100644 (file)
@@ -134,7 +134,8 @@ func testTestDir(t *testing.T, path string, ignore ...string) {
                // parse and type-check file
                file, err := parser.ParseFile(fset, filename, nil, 0)
                if err == nil {
-                       conf := Config{GoVersion: goVersion, Importer: stdLibImporter}
+                       conf := Config{Importer: stdLibImporter}
+                       SetGoVersion(&conf, goVersion)
                        _, err = conf.Check(filename, fset, []*ast.File{file}, nil)
                }
 
index fd9462c4a27a3e856b6b0a727cb080773f3698c2..25cd9966282861ebf71827819813f0e9b44908d0 100644 (file)
@@ -11,3 +11,9 @@ import "sync/atomic"
 // for tests where we may want to have a consistent
 // numbering for each individual test case.
 func ResetId() { atomic.StoreUint32(&lastId, 0) }
+
+// SetGoVersion sets the unexported goVersion field on config, so that tests
+// which assert on behavior for older Go versions can set it.
+func SetGoVersion(config *Config, goVersion string) {
+       config.goVersion = goVersion
+}