Bläddra i källkod

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>
Damien Neil 6 år sedan
förälder
incheckning
95758c0892
2 ändrade filer med 16 tillägg och 10 borttagningar
  1. 11 8
      internal/filedesc/build.go
  2. 5 2
      internal/filetype/build.go

+ 11 - 8
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)

+ 5 - 2
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 {