]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: export Info.FileVersions
authorRobert Griesemer <gri@golang.org>
Tue, 7 Nov 2023 00:42:27 +0000 (16:42 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 7 Nov 2023 16:52:44 +0000 (16:52 +0000)
For #62605.

Change-Id: Icf1a8332e4b60d77607716b55893ea2f39ae2f10
Reviewed-on: https://go-review.googlesource.com/c/go/+/540056
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

api/next/62605.txt [new file with mode: 0644]
src/go/types/api.go
src/go/types/api_test.go
src/go/types/check.go

diff --git a/api/next/62605.txt b/api/next/62605.txt
new file mode 100644 (file)
index 0000000..1b0e533
--- /dev/null
@@ -0,0 +1 @@
+pkg go/types, type Info struct, FileVersions map[*ast.File]string #62605
index 33633ea83cb3ee0542360db30dec7aa75fe12f3f..81a98f7e663882e17938176b6797b0eb63d5d568 100644 (file)
@@ -286,11 +286,12 @@ type Info struct {
        // appear in this list.
        InitOrder []*Initializer
 
-       // _FileVersions maps a file to the file's Go version string.
-       // If the file doesn't specify a version and Config.GoVersion
-       // is not given, the reported version is the empty string.
-       // TODO(gri) should this be "go0.0" instead in that case?
-       _FileVersions map[*ast.File]string
+       // FileVersions maps a file to its Go version string.
+       // If the file doesn't specify a version, the reported
+       // string is Config.GoVersion.
+       // Version strings begin with “go”, like “go1.21”, and
+       // are suitable for use with the [go/version] package.
+       FileVersions map[*ast.File]string
 }
 
 func (info *Info) recordTypes() bool {
index f3719ddf6d226d699f485f92c86112d68fd95465..0769890101caf02c40303ae66c6d319fa020839f 100644 (file)
@@ -2796,7 +2796,7 @@ func TestFileVersions(t *testing.T) {
                conf := Config{GoVersion: test.moduleVersion}
                versions := make(map[*ast.File]string)
                var info Info
-               *_FileVersionsAddr(&info) = versions
+               info.FileVersions = versions
                mustTypecheck(src, &conf, &info)
 
                n := 0
@@ -2812,9 +2812,3 @@ func TestFileVersions(t *testing.T) {
                }
        }
 }
-
-// _FileVersionsAddr(conf) returns the address of the field info._FileVersions.
-func _FileVersionsAddr(info *Info) *map[*ast.File]string {
-       v := reflect.Indirect(reflect.ValueOf(info))
-       return (*map[*ast.File]string)(v.FieldByName("_FileVersions").Addr().UnsafePointer())
-}
index 99696de496125c8e1878f49aec2bf1ed0be01e37..89b8ee07a25d9f71049a7be0281a3cdce61e56c7 100644 (file)
@@ -634,7 +634,7 @@ func (check *Checker) recordScope(node ast.Node, scope *Scope) {
 }
 
 func (check *Checker) recordFileVersion(file *ast.File, version string) {
-       if m := check._FileVersions; m != nil {
+       if m := check.FileVersions; m != nil {
                m[file] = version
        }
 }