Skip to content

Commit

Permalink
go/packages: document that types.Sizes may be nil
Browse files Browse the repository at this point in the history
This is not a behavior change.

Change-Id: Ia70c01ff0893b2274b44fb0f2043dbcb6afb71c8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/537116
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan committed Oct 23, 2023
1 parent 5185da1 commit 02048e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ type Package struct {
TypesInfo *types.Info

// TypesSizes provides the effective size function for types in TypesInfo.
// It may be nil if, for example, the compiler/architecture pair is not known.
TypesSizes types.Sizes

// forTest is the package under test, if any.
Expand Down Expand Up @@ -553,7 +554,7 @@ type loaderPackage struct {
type loader struct {
pkgs map[string]*loaderPackage
Config
sizes types.Sizes
sizes types.Sizes // nil => unknown
parseCache map[string]*parseValue
parseCacheMu sync.Mutex
exportMu sync.Mutex // enforces mutual exclusion of exportdata operations
Expand Down Expand Up @@ -1042,7 +1043,7 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
IgnoreFuncBodies: ld.Mode&NeedDeps == 0 && !lpkg.initial,

Error: appendError,
Sizes: ld.sizes,
Sizes: ld.sizes, // may be nil
}
if lpkg.Module != nil && lpkg.Module.GoVersion != "" {
typesinternal.SetGoVersion(tc, "go"+lpkg.Module.GoVersion)
Expand Down

0 comments on commit 02048e6

Please sign in to comment.