internal/filetype, internal/filedesc: avoid gccgo bug

Returning an anonymous struct is tickling a gccgo bug:
https://github.com/golang/go/issues/33866

Change to a named type. We could make the type unexpoerted, but this is
an internal package anyway so leave it exported for general style
cleanliness.

Change-Id: Idf33f1e354c0e07066ab68640308af1498a01447
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191960
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Damien Neil 2019-08-27 08:44:46 -07:00
parent 26aef9d6d6
commit 95758c0892
2 changed files with 16 additions and 10 deletions

View File

@ -65,13 +65,8 @@ const (
listMethOutDeps
)
// Build constructs a FileDescriptor given the parameters set in Builder.
// It assumes that the inputs are well-formed and panics if any inconsistencies
// are encountered.
//
// If NumEnums+NumMessages+NumExtensions+NumServices is zero,
// then Build automatically derives them from the raw descriptor.
func (db Builder) Build() (out struct {
// Out is the output of the Builder.
type Out struct {
File pref.FileDescriptor
// Enums is all enum descriptors in "flattened ordering".
@ -83,7 +78,15 @@ func (db Builder) Build() (out struct {
Extensions []Extension
// Service is all service descriptors in "flattened ordering".
Services []Service
}) {
}
// Build constructs a FileDescriptor given the parameters set in Builder.
// It assumes that the inputs are well-formed and panics if any inconsistencies
// are encountered.
//
// If NumEnums+NumMessages+NumExtensions+NumServices is zero,
// then Build automatically derives them from the raw descriptor.
func (db Builder) Build() (out Out) {
// Populate the counts if uninitialized.
if db.NumEnums+db.NumMessages+db.NumExtensions+db.NumServices == 0 {
db.unmarshalCounts(db.RawDescriptor, true)

View File

@ -112,9 +112,12 @@ type Builder struct {
}
}
func (tb Builder) Build() (out struct {
// Out is the output of the builder.
type Out struct {
File pref.FileDescriptor
}) {
}
func (tb Builder) Build() (out Out) {
// Replace the resolver with one that resolves dependencies by index,
// which is faster and more reliable than relying on the global registry.
if tb.File.FileRegistry == nil {