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>
--- /dev/null
+pkg go/types, type Info struct, FileVersions map[*ast.File]string #62605
// 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 {
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
}
}
}
-
-// _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())
-}
}
func (check *Checker) recordFileVersion(file *ast.File, version string) {
- if m := check._FileVersions; m != nil {
+ if m := check.FileVersions; m != nil {
m[file] = version
}
}