go/packages: add NeedTypesSizes to LoadTypes
This change moves the NeedTypesSizes bit to LoadTypes instead of LoadSyntax.
Fixes golang/go#31163
Change-Id: Icaf16639202533fbb2190756a325b36d8ac9251c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/170016
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/go/packages/packages.go b/go/packages/packages.go
index 36e54a3..7d0198f 100644
--- a/go/packages/packages.go
+++ b/go/packages/packages.go
@@ -88,14 +88,14 @@
// LoadTypes adds type information for package-level
// declarations in the packages matching the patterns.
- // Package fields added: Types, Fset, and IllTyped.
+ // Package fields added: Types, TypesSizes, Fset, and IllTyped.
// This mode uses type information provided by the build system when
// possible, and may fill in the ExportFile field.
- LoadTypes = LoadImports | NeedTypes
+ LoadTypes = LoadImports | NeedTypes | NeedTypesSizes
// LoadSyntax adds typed syntax trees for the packages matching the patterns.
// Package fields added: Syntax, and TypesInfo, for direct pattern matches only.
- LoadSyntax = LoadTypes | NeedSyntax | NeedTypesInfo | NeedTypesSizes
+ LoadSyntax = LoadTypes | NeedSyntax | NeedTypesInfo
// LoadAllSyntax adds typed syntax trees for the packages matching the patterns
// and all dependencies.
diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go
index bff6409..85a6b31 100644
--- a/go/packages/packages_test.go
+++ b/go/packages/packages_test.go
@@ -569,6 +569,8 @@
continue
} else if !p.Types.Complete() {
t.Errorf("incomplete types.Package for %s", p)
+ } else if p.TypesSizes == nil {
+ t.Errorf("TypesSizes is not filled in for %s", p)
}
}