mirror of
https://github.com/golang/go
synced 2024-11-22 10:34:46 -07:00
go/types: export Info.FileVersions
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>
This commit is contained in:
parent
cae35cd258
commit
43a27a7e8c
1
api/next/62605.txt
Normal file
1
api/next/62605.txt
Normal file
@ -0,0 +1 @@
|
||||
pkg go/types, type Info struct, FileVersions map[*ast.File]string #62605
|
@ -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 {
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user