From 95758c08929ff71cd4a51def17d314adf46a6be5 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 27 Aug 2019 08:44:46 -0700 Subject: [PATCH] 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 --- internal/filedesc/build.go | 19 +++++++++++-------- internal/filetype/build.go | 7 +++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/filedesc/build.go b/internal/filedesc/build.go index 916b89a3..37194552 100644 --- a/internal/filedesc/build.go +++ b/internal/filedesc/build.go @@ -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) diff --git a/internal/filetype/build.go b/internal/filetype/build.go index 965ff27e..b89a688c 100644 --- a/internal/filetype/build.go +++ b/internal/filetype/build.go @@ -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 {