cmd/protoc-gen-go: reduce technical debt

The following TODOs were addressed:
* Consistently collect all enums, messages, and extensions in a breadth-first order.
The practical affect of this is that the declaration order in a Go file may change.
This simplifies reflection generation, which relies on consistent ordering.
* Removal of placeholder declarations (e.g., "var _ = proto.Marshal") since
protogen is intelligent about including imports as necessary.
* Always generate a default variable or constant for explicit empty strings.
The practical effect of this is the addition of new declarations in some cases.
However, it simplifies our logic such that it matches the protobuf data model.
* Generate the registration statements in a consistent order.

Change-Id: I627bb72589432bb65d53b50965ea88e5f7983977
Reviewed-on: https://go-review.googlesource.com/c/152778
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
index f07e521..f75c1c7 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
@@ -4,27 +4,18 @@
 package grpc
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
 // proto package needs to be updated.
 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
 
-func init() { proto.RegisterFile("grpc/deprecation.proto", fileDescriptor_1e7146702b7fe8c5) }
-
 var fileDescriptor_1e7146702b7fe8c5 = []byte{
 	// 184 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x2f, 0x2a, 0x48,
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
index 79ee7ee..5511e59 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
@@ -4,19 +4,12 @@
 package grpc
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -124,12 +117,11 @@
 var xxx_messageInfo_Response proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("grpc/grpc.proto", fileDescriptor_81ea47a3f88c2082)
 	proto.RegisterType((*Request)(nil), "goproto.protoc.grpc.Request")
 	proto.RegisterType((*Response)(nil), "goproto.protoc.grpc.Response")
 }
 
-func init() { proto.RegisterFile("grpc/grpc.proto", fileDescriptor_81ea47a3f88c2082) }
-
 var fileDescriptor_81ea47a3f88c2082 = []byte{
 	// 211 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4f, 0x2f, 0x2a, 0x48,
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index d64b2da..7b129d4 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -40,11 +40,12 @@
 type fileInfo struct {
 	*protogen.File
 	descriptorVar string // var containing the gzipped FileDescriptorProto
-	allEnums      []*protogen.Enum
-	allMessages   []*protogen.Message
-	allExtensions []*protogen.Extension
 
-	fileReflect fileReflect
+	allEnums         []*protogen.Enum
+	allEnumsByPtr    map[*protogen.Enum]int // value is index into allEnums
+	allMessages      []*protogen.Message
+	allMessagesByPtr map[*protogen.Message]int // value is index into allMessages
+	allExtensions    []*protogen.Extension
 }
 
 // protoPackage returns the package to import, which is either the protoPackage
@@ -75,20 +76,30 @@
 		File: file,
 	}
 
-	// The different order for enums and extensions is to match the output
-	// of the previous implementation.
-	//
-	// TODO: Eventually make this consistent (and remove fileReflect).
-	f.allEnums = append(f.allEnums, f.File.Enums...)
-	walkMessages(f.Messages, func(message *protogen.Message) {
-		f.allMessages = append(f.allMessages, message)
-		f.allEnums = append(f.allEnums, message.Enums...)
-		f.allExtensions = append(f.allExtensions, message.Extensions...)
+	// Collect all enums, messages, and extensions in a breadth-first order.
+	f.allEnums = append(f.allEnums, f.Enums...)
+	f.allMessages = append(f.allMessages, f.Messages...)
+	f.allExtensions = append(f.allExtensions, f.Extensions...)
+	walkMessages(f.Messages, func(m *protogen.Message) {
+		f.allEnums = append(f.allEnums, m.Enums...)
+		f.allMessages = append(f.allMessages, m.Messages...)
+		f.allExtensions = append(f.allExtensions, m.Extensions...)
 	})
-	f.allExtensions = append(f.allExtensions, f.File.Extensions...)
 
-	// Initialize data structures needed for reflection.
-	f.fileReflect.init(f)
+	// Derive a reverse mapping of enum and message pointers to their index
+	// in allEnums and allMessages.
+	if len(f.allEnums) > 0 {
+		f.allEnumsByPtr = make(map[*protogen.Enum]int)
+		for i, e := range f.allEnums {
+			f.allEnumsByPtr[e] = i
+		}
+	}
+	if len(f.allMessages) > 0 {
+		f.allMessagesByPtr = make(map[*protogen.Message]int)
+		for i, m := range f.allMessages {
+			f.allMessagesByPtr[m] = i
+		}
+	}
 
 	// Determine the name of the var holding the file descriptor:
 	//
@@ -118,15 +129,7 @@
 	// This section exists to generate output more consistent with
 	// the previous version of protoc-gen-go, to make it easier to
 	// detect unintended variations.
-	//
-	// TODO: Eventually remove this.
 	if !isDescriptor(file) {
-		g.P("// Reference imports to suppress errors if they are not otherwise used.")
-		g.P("var _ = ", protoPackage.Ident("Marshal"))
-		g.P("var _ = ", fmtPackage.Ident("Errorf"))
-		g.P("var _ = ", mathPackage.Ident("Inf"))
-		g.P()
-
 		g.P("// This is a compile-time assertion to ensure that this generated file")
 		g.P("// is compatible with the proto package it is being compiled against.")
 		g.P("// A compilation error at this line likely means your copy of the")
@@ -145,7 +148,7 @@
 	for _, message := range f.allMessages {
 		genMessage(gen, g, f, message)
 	}
-	for _, extension := range f.Extensions {
+	for _, extension := range f.allExtensions {
 		genExtension(gen, g, f, extension)
 	}
 
@@ -197,7 +200,7 @@
 		}
 		enums = append(enums, message.Enums...)
 		for _, field := range message.Fields {
-			if !fieldHasDefault(field) {
+			if !field.Desc.HasDefault() {
 				continue
 			}
 			defVar := protogen.GoIdent{
@@ -260,8 +263,6 @@
 	w.Close()
 	b = buf.Bytes()
 
-	g.P("func init() {", f.protoPackage().Ident("RegisterFile"), "(", strconv.Quote(f.Desc.Path()), ", ", f.descriptorVar, ") }")
-	g.P()
 	g.P("var ", f.descriptorVar, " = []byte{")
 	g.P("// ", len(b), " bytes of a gzipped FileDescriptorProto")
 	for len(b) > 0 {
@@ -436,7 +437,6 @@
 		tags = append(tags, `json:"-"`)
 		g.P(f.protoPackage().Ident("XXX_InternalExtensions"), " `", strings.Join(tags, " "), "`")
 	}
-	// TODO XXX_InternalExtensions
 	g.P("XXX_unrecognized []byte `json:\"-\"`")
 	g.P("XXX_sizecache int32 `json:\"-\"`")
 	g.P("}")
@@ -519,7 +519,7 @@
 
 	// Constants and vars holding the default values of fields.
 	for _, field := range message.Fields {
-		if !fieldHasDefault(field) {
+		if !field.Desc.HasDefault() {
 			continue
 		}
 		defVarName := "Default_" + message.GoIdent.GoName + "_" + field.GoName
@@ -606,9 +606,6 @@
 	if len(message.Oneofs) > 0 {
 		genOneofWrappers(gen, g, f, message)
 	}
-	for _, extension := range message.Extensions {
-		genExtension(gen, g, f, extension)
-	}
 }
 
 // fieldGoType returns the Go type used for a field.
@@ -670,7 +667,7 @@
 	if field.Desc.Cardinality() == protoreflect.Repeated {
 		return "nil"
 	}
-	if fieldHasDefault(field) {
+	if field.Desc.HasDefault() {
 		defVarName := "Default_" + message.GoIdent.GoName + "_" + field.GoName
 		if field.Desc.Kind() == protoreflect.BytesKind {
 			return "append([]byte(nil), " + defVarName + "...)"
@@ -691,26 +688,6 @@
 	}
 }
 
-// fieldHasDefault returns true if we consider a field to have a default value.
-//
-// For consistency with the previous generator, it returns false for fields with
-// [default=""], preventing the generation of a default const or var for these
-// fields.
-//
-// TODO: Drop this special case.
-func fieldHasDefault(field *protogen.Field) bool {
-	if !field.Desc.HasDefault() {
-		return false
-	}
-	switch field.Desc.Kind() {
-	case protoreflect.StringKind:
-		return field.Desc.Default().String() != ""
-	case protoreflect.BytesKind:
-		return len(field.Desc.Default().Bytes()) > 0
-	}
-	return true
-}
-
 func fieldJSONTag(field *protogen.Field) string {
 	return string(field.Desc.Name()) + ",omitempty"
 }
@@ -785,6 +762,7 @@
 	}
 
 	g.P("func init() {")
+	g.P(f.protoPackage().Ident("RegisterFile"), "(", strconv.Quote(f.Desc.Path()), ", ", f.descriptorVar, ")")
 	for _, enum := range f.allEnums {
 		name := enum.GoIdent.GoName
 		g.P(f.protoPackage().Ident("RegisterEnum"), fmt.Sprintf("(%q, %s_name, %s_value)", enumRegistryName(enum), name, name))
@@ -794,10 +772,6 @@
 			continue
 		}
 
-		for _, extension := range message.Extensions {
-			genRegisterExtension(gen, g, f, extension)
-		}
-
 		name := message.GoIdent.GoName
 		g.P(f.protoPackage().Ident("RegisterType"), fmt.Sprintf("((*%s)(nil), %q)", name, message.Desc.FullName()))
 
@@ -819,17 +793,13 @@
 			g.P(f.protoPackage().Ident("RegisterMapType"), fmt.Sprintf("((%v)(nil), %q)", goType, typeName))
 		}
 	}
-	for _, extension := range f.Extensions {
-		genRegisterExtension(gen, g, f, extension)
+	for _, extension := range f.allExtensions {
+		g.P(f.protoPackage().Ident("RegisterExtension"), "(", extensionVar(f.File, extension), ")")
 	}
 	g.P("}")
 	g.P()
 }
 
-func genRegisterExtension(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, extension *protogen.Extension) {
-	g.P(f.protoPackage().Ident("RegisterExtension"), "(", extensionVar(f.File, extension), ")")
-}
-
 // deprecationComment returns a standard deprecation comment if deprecated is true.
 func deprecationComment(deprecated bool) string {
 	if !deprecated {
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 9200910..6b6ea68 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -42,48 +42,12 @@
 
 // TODO: Add support for proto options.
 
-// fileReflect is embedded in fileInfo to maintain state needed for reflection.
-//
-// TODO: Remove this when we have the freedom to change the order of
-// fileInfo.{allEnums,allMessages,allExtensions} to be a breadth-first search
-// to ensure that all declarations are coalesced together.
-type fileReflect struct {
-	allEnums         []*protogen.Enum
-	allEnumsByPtr    map[*protogen.Enum]int // value is index into allEnums
-	allMessages      []*protogen.Message
-	allMessagesByPtr map[*protogen.Message]int // value is index into allMessages
-}
-
-func (r *fileReflect) init(f *fileInfo) {
-	r.allEnums = append(r.allEnums, f.Enums...)
-	r.allMessages = append(r.allMessages, f.Messages...)
-	walkMessages(f.Messages, func(m *protogen.Message) {
-		r.allEnums = append(r.allEnums, m.Enums...)
-		r.allMessages = append(r.allMessages, m.Messages...)
-	})
-
-	// Derive a reverse mapping of enum and message pointers to their index
-	// in allEnums and allMessages.
-	if len(r.allEnums) > 0 {
-		r.allEnumsByPtr = make(map[*protogen.Enum]int)
-		for i, e := range r.allEnums {
-			r.allEnumsByPtr[e] = i
-		}
-	}
-	if len(r.allMessages) > 0 {
-		r.allMessagesByPtr = make(map[*protogen.Message]int)
-		for i, m := range r.allMessages {
-			r.allMessagesByPtr[m] = i
-		}
-	}
-}
-
 func genReflectInitFunction(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
 	if !enableReflection(f.File) {
 		return
 	}
 
-	if len(f.fileReflect.allEnums)+len(f.fileReflect.allMessages)+len(f.allExtensions)+len(f.Services) == 0 {
+	if len(f.allEnums)+len(f.allMessages)+len(f.allExtensions)+len(f.Services) == 0 {
 		return
 	}
 
@@ -103,20 +67,20 @@
 	// Populate all declarations for messages and enums.
 	// These are not declared in the literals to avoid an initialization loop.
 	if enums := f.Enums; len(enums) > 0 {
-		i := f.fileReflect.allEnumsByPtr[enums[0]]
+		i := f.allEnumsByPtr[enums[0]]
 		g.P(fileDescVar, ".Enums = ", enumDescsVar, "[", i, ":", i+len(enums), "]")
 	}
 	if messages := f.Messages; len(messages) > 0 {
-		i := f.fileReflect.allMessagesByPtr[messages[0]]
+		i := f.allMessagesByPtr[messages[0]]
 		g.P(fileDescVar, ".Messages = ", messageDescsVar, "[", i, ":", i+len(messages), "]")
 	}
-	for i, message := range f.fileReflect.allMessages {
+	for i, message := range f.allMessages {
 		if enums := message.Enums; len(enums) > 0 {
-			j := f.fileReflect.allEnumsByPtr[enums[0]]
+			j := f.allEnumsByPtr[enums[0]]
 			g.P(messageDescsVar, "[", i, "].Enums = ", enumDescsVar, "[", j, ":", j+len(enums), "]")
 		}
 		if messages := message.Messages; len(messages) > 0 {
-			j := f.fileReflect.allMessagesByPtr[messages[0]]
+			j := f.allMessagesByPtr[messages[0]]
 			g.P(messageDescsVar, "[", i, "].Messages = ", messageDescsVar, "[", j, ":", j+len(messages), "]")
 		}
 	}
@@ -127,11 +91,11 @@
 	// v2 protobuf reflection interfaces. The EnumTypeOf and MessageTypeOf
 	// helper functions checks for compliance and derives a v2 type from the
 	// legacy v1 enum or message if necessary.
-	for i, message := range f.fileReflect.allMessages {
+	for i, message := range f.allMessages {
 		for j, field := range message.Fields {
 			fieldSel := fmt.Sprintf("[%d].Fields[%d]", i, j)
 			if et := field.EnumType; et != nil {
-				idx, ok := f.fileReflect.allEnumsByPtr[et]
+				idx, ok := f.allEnumsByPtr[et]
 				if ok {
 					// Locally defined enums are found in the type array.
 					g.P(messageDescsVar, fieldSel, ".EnumType = ", enumTypesVar, "[", idx, "]")
@@ -141,7 +105,7 @@
 				}
 			}
 			if mt := field.MessageType; mt != nil {
-				idx, ok := f.fileReflect.allMessagesByPtr[mt]
+				idx, ok := f.allMessagesByPtr[mt]
 				if ok {
 					if mt.Desc.IsMapEntry() {
 						// Map entry types have no Go type generated for them.
@@ -209,11 +173,11 @@
 	g.P("}")
 
 	// Generate literals for enum descriptors.
-	if len(f.fileReflect.allEnums) > 0 {
+	if len(f.allEnums) > 0 {
 		enumTypesVar := enumTypesVarName(f)
 		enumDescsVar := enumDescsVarName(f)
-		g.P("var ", enumTypesVar, " = [", len(f.fileReflect.allEnums), "]", protoreflectPackage.Ident("EnumType"), "{")
-		for i, enum := range f.fileReflect.allEnums {
+		g.P("var ", enumTypesVar, " = [", len(f.allEnums), "]", protoreflectPackage.Ident("EnumType"), "{")
+		for i, enum := range f.allEnums {
 			g.P(prototypePackage.Ident("GoEnum"), "(")
 			g.P(enumDescsVar, "[", i, "].Reference(),")
 			g.P("func(_ ", protoreflectPackage.Ident("EnumType"), ", n ", protoreflectPackage.Ident("EnumNumber"), ") ", protoreflectPackage.Ident("ProtoEnum"), " {")
@@ -223,8 +187,8 @@
 		}
 		g.P("}")
 
-		g.P("var ", enumDescsVar, " = [", len(f.fileReflect.allEnums), "]", prototypePackage.Ident("Enum"), "{")
-		for _, enum := range f.fileReflect.allEnums {
+		g.P("var ", enumDescsVar, " = [", len(f.allEnums), "]", prototypePackage.Ident("Enum"), "{")
+		for _, enum := range f.allEnums {
 			g.P("{")
 			g.P("Name: ", strconv.Quote(string(enum.Desc.Name())), ",")
 			g.P("Values: []", prototypePackage.Ident("EnumValue"), "{")
@@ -238,11 +202,11 @@
 	}
 
 	// Generate literals for message descriptors.
-	if len(f.fileReflect.allMessages) > 0 {
+	if len(f.allMessages) > 0 {
 		messageTypesVar := messageTypesVarName(f)
 		messageDescsVar := messageDescsVarName(f)
-		g.P("var ", messageTypesVar, " = [", len(f.fileReflect.allMessages), "]", protoimplPackage.Ident("MessageType"), "{")
-		for i, message := range f.fileReflect.allMessages {
+		g.P("var ", messageTypesVar, " = [", len(f.allMessages), "]", protoimplPackage.Ident("MessageType"), "{")
+		for i, message := range f.allMessages {
 			if message.Desc.IsMapEntry() {
 				// Map entry types have no Go type generated for them.
 				g.P("{ /* no message type for ", message.GoIdent, " */ },")
@@ -257,8 +221,8 @@
 		}
 		g.P("}")
 
-		g.P("var ", messageDescsVar, " = [", len(f.fileReflect.allMessages), "]", prototypePackage.Ident("Message"), "{")
-		for _, message := range f.fileReflect.allMessages {
+		g.P("var ", messageDescsVar, " = [", len(f.allMessages), "]", prototypePackage.Ident("Message"), "{")
+		for _, message := range f.allMessages {
 			g.P("{")
 			g.P("Name: ", strconv.Quote(string(message.Desc.Name())), ",")
 			if fields := message.Desc.Fields(); fields.Len() > 0 {
@@ -337,7 +301,7 @@
 	g.P("type ", shadowType, " ", enum.GoIdent)
 	g.P()
 
-	idx := f.fileReflect.allEnumsByPtr[enum]
+	idx := f.allEnumsByPtr[enum]
 	typesVar := enumTypesVarName(f)
 	g.P("func (e ", enum.GoIdent, ") ProtoReflect() ", protoreflectPackage.Ident("Enum"), " {")
 	g.P("return (", shadowType, ")(e)")
@@ -359,7 +323,7 @@
 	g.P("type ", shadowType, " struct{m *", message.GoIdent, "}")
 	g.P()
 
-	idx := f.fileReflect.allMessagesByPtr[message]
+	idx := f.allMessagesByPtr[message]
 	typesVar := messageTypesVarName(f)
 	g.P("func (m *", message.GoIdent, ") ProtoReflect() ", protoreflectPackage.Ident("Message"), " {")
 	g.P("return ", shadowType, "{m}")
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index f464c2c..6fa2387 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -4,19 +4,12 @@
 package annotations
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -131,12 +124,11 @@
 }
 
 func init() {
+	proto.RegisterFile("annotations/annotations.proto", fileDescriptor_21dfaf6fd39fa3b7)
 	proto.RegisterEnum("goproto.protoc.annotations.AnnotationsTestEnum", AnnotationsTestEnum_name, AnnotationsTestEnum_value)
 	proto.RegisterType((*AnnotationsTestMessage)(nil), "goproto.protoc.annotations.AnnotationsTestMessage")
 }
 
-func init() { proto.RegisterFile("annotations/annotations.proto", fileDescriptor_21dfaf6fd39fa3b7) }
-
 var fileDescriptor_21dfaf6fd39fa3b7 = []byte{
 	// 194 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xcc, 0xcb, 0xcb,
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index dc96538..7a3af63 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -6,19 +6,12 @@
 package comments
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -122,6 +115,57 @@
 	}
 }
 
+// COMMENT: Message2
+type Message2 struct {
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+type xxx_Message2 struct{ m *Message2 }
+
+func (m *Message2) ProtoReflect() protoreflect.Message {
+	return xxx_Message2{m}
+}
+func (m xxx_Message2) Type() protoreflect.MessageType {
+	return xxx_Comments_ProtoFile_MessageTypes[1].Type
+}
+func (m xxx_Message2) KnownFields() protoreflect.KnownFields {
+	return xxx_Comments_ProtoFile_MessageTypes[1].KnownFieldsOf(m.m)
+}
+func (m xxx_Message2) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Comments_ProtoFile_MessageTypes[1].UnknownFieldsOf(m.m)
+}
+func (m xxx_Message2) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_Message2) ProtoMutable() {}
+
+func (m *Message2) Reset()         { *m = Message2{} }
+func (m *Message2) String() string { return proto.CompactTextString(m) }
+func (*Message2) ProtoMessage()    {}
+func (*Message2) Descriptor() ([]byte, []int) {
+	return fileDescriptor_885e8293f1fab554, []int{1}
+}
+
+func (m *Message2) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_Message2.Unmarshal(m, b)
+}
+func (m *Message2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_Message2.Marshal(b, m, deterministic)
+}
+func (m *Message2) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_Message2.Merge(m, src)
+}
+func (m *Message2) XXX_Size() int {
+	return xxx_messageInfo_Message2.Size(m)
+}
+func (m *Message2) XXX_DiscardUnknown() {
+	xxx_messageInfo_Message2.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Message2 proto.InternalMessageInfo
+
 // COMMENT: Message1A
 type Message1_Message1A struct {
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -224,57 +268,6 @@
 
 var xxx_messageInfo_Message1_Message1B proto.InternalMessageInfo
 
-// COMMENT: Message2
-type Message2 struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_Message2 struct{ m *Message2 }
-
-func (m *Message2) ProtoReflect() protoreflect.Message {
-	return xxx_Message2{m}
-}
-func (m xxx_Message2) Type() protoreflect.MessageType {
-	return xxx_Comments_ProtoFile_MessageTypes[1].Type
-}
-func (m xxx_Message2) KnownFields() protoreflect.KnownFields {
-	return xxx_Comments_ProtoFile_MessageTypes[1].KnownFieldsOf(m.m)
-}
-func (m xxx_Message2) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Comments_ProtoFile_MessageTypes[1].UnknownFieldsOf(m.m)
-}
-func (m xxx_Message2) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_Message2) ProtoMutable() {}
-
-func (m *Message2) Reset()         { *m = Message2{} }
-func (m *Message2) String() string { return proto.CompactTextString(m) }
-func (*Message2) ProtoMessage()    {}
-func (*Message2) Descriptor() ([]byte, []int) {
-	return fileDescriptor_885e8293f1fab554, []int{1}
-}
-
-func (m *Message2) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_Message2.Unmarshal(m, b)
-}
-func (m *Message2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_Message2.Marshal(b, m, deterministic)
-}
-func (m *Message2) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Message2.Merge(m, src)
-}
-func (m *Message2) XXX_Size() int {
-	return xxx_messageInfo_Message2.Size(m)
-}
-func (m *Message2) XXX_DiscardUnknown() {
-	xxx_messageInfo_Message2.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Message2 proto.InternalMessageInfo
-
 // COMMENT: Message2A
 type Message2_Message2A struct {
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -378,16 +371,15 @@
 var xxx_messageInfo_Message2_Message2B proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("comments/comments.proto", fileDescriptor_885e8293f1fab554)
 	proto.RegisterType((*Message1)(nil), "goproto.protoc.comments.Message1")
+	proto.RegisterType((*Message2)(nil), "goproto.protoc.comments.Message2")
 	proto.RegisterType((*Message1_Message1A)(nil), "goproto.protoc.comments.Message1.Message1A")
 	proto.RegisterType((*Message1_Message1B)(nil), "goproto.protoc.comments.Message1.Message1B")
-	proto.RegisterType((*Message2)(nil), "goproto.protoc.comments.Message2")
 	proto.RegisterType((*Message2_Message2A)(nil), "goproto.protoc.comments.Message2.Message2A")
 	proto.RegisterType((*Message2_Message2B)(nil), "goproto.protoc.comments.Message2.Message2B")
 }
 
-func init() { proto.RegisterFile("comments/comments.proto", fileDescriptor_885e8293f1fab554) }
-
 var fileDescriptor_885e8293f1fab554 = []byte{
 	// 191 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xce, 0xcf, 0xcd,
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index 7948064..721f586 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -4,19 +4,12 @@
 package comments
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -117,12 +110,11 @@
 }
 
 func init() {
+	proto.RegisterFile("comments/deprecated.proto", fileDescriptor_0336e614ee2de5f7)
 	proto.RegisterEnum("goproto.protoc.comments.DeprecatedEnum", DeprecatedEnum_name, DeprecatedEnum_value)
 	proto.RegisterType((*DeprecatedMessage)(nil), "goproto.protoc.comments.DeprecatedMessage")
 }
 
-func init() { proto.RegisterFile("comments/deprecated.proto", fileDescriptor_0336e614ee2de5f7) }
-
 var fileDescriptor_0336e614ee2de5f7 = []byte{
 	// 206 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xce, 0xcf, 0xcd,
diff --git a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
index 45f59fc..57db78b 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -4,19 +4,12 @@
 package base
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -151,12 +144,11 @@
 var xxx_messageInfo_MessageSetWireFormatMessage proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("extensions/base/base.proto", fileDescriptor_aebb28f8d5a04466)
 	proto.RegisterType((*BaseMessage)(nil), "goproto.protoc.extension.base.BaseMessage")
 	proto.RegisterType((*MessageSetWireFormatMessage)(nil), "goproto.protoc.extension.base.MessageSetWireFormatMessage")
 }
 
-func init() { proto.RegisterFile("extensions/base/base.proto", fileDescriptor_aebb28f8d5a04466) }
-
 var fileDescriptor_aebb28f8d5a04466 = []byte{
 	// 204 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xad, 0x28, 0x49,
diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
index 38dd2d4..26b96d9 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -4,21 +4,14 @@
 package ext
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	base "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/base"
 	extra "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/extra"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -132,56 +125,6 @@
 	return nil
 }
 
-type Message_M struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_Message_M struct{ m *Message_M }
-
-func (m *Message_M) ProtoReflect() protoreflect.Message {
-	return xxx_Message_M{m}
-}
-func (m xxx_Message_M) Type() protoreflect.MessageType {
-	return xxx_Ext_ProtoFile_MessageTypes[6].Type
-}
-func (m xxx_Message_M) KnownFields() protoreflect.KnownFields {
-	return xxx_Ext_ProtoFile_MessageTypes[6].KnownFieldsOf(m.m)
-}
-func (m xxx_Message_M) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Ext_ProtoFile_MessageTypes[6].UnknownFieldsOf(m.m)
-}
-func (m xxx_Message_M) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_Message_M) ProtoMutable() {}
-
-func (m *Message_M) Reset()         { *m = Message_M{} }
-func (m *Message_M) String() string { return proto.CompactTextString(m) }
-func (*Message_M) ProtoMessage()    {}
-func (*Message_M) Descriptor() ([]byte, []int) {
-	return fileDescriptor_bf470ef4907b23cb, []int{0, 0}
-}
-
-func (m *Message_M) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_Message_M.Unmarshal(m, b)
-}
-func (m *Message_M) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_Message_M.Marshal(b, m, deterministic)
-}
-func (m *Message_M) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Message_M.Merge(m, src)
-}
-func (m *Message_M) XXX_Size() int {
-	return xxx_messageInfo_Message_M.Size(m)
-}
-func (m *Message_M) XXX_DiscardUnknown() {
-	xxx_messageInfo_Message_M.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_Message_M proto.InternalMessageInfo
-
 type ExtensionGroup struct {
 	ExtensionGroup       *string  `protobuf:"bytes,120,opt,name=extension_group,json=extensionGroup" json:"extension_group,omitempty"`
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -291,80 +234,6 @@
 
 var xxx_messageInfo_ExtendingMessage proto.InternalMessageInfo
 
-var E_ExtendingMessage_ExtendingMessageString = &proto.ExtensionDesc{
-	ExtendedType:  (*base.BaseMessage)(nil),
-	ExtensionType: (*string)(nil),
-	Field:         200,
-	Name:          "goproto.protoc.extension.ext.ExtendingMessage.extending_message_string",
-	Tag:           "bytes,200,opt,name=extending_message_string",
-	Filename:      "extensions/ext/ext.proto",
-}
-
-var E_ExtendingMessage_ExtendingMessageSubmessage = &proto.ExtensionDesc{
-	ExtendedType:  (*base.BaseMessage)(nil),
-	ExtensionType: (*ExtendingMessage_ExtendingMessageSubmessage)(nil),
-	Field:         201,
-	Name:          "goproto.protoc.extension.ext.ExtendingMessage.extending_message_submessage",
-	Tag:           "bytes,201,opt,name=extending_message_submessage",
-	Filename:      "extensions/ext/ext.proto",
-}
-
-type ExtendingMessage_ExtendingMessageSubmessage struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_ExtendingMessage_ExtendingMessageSubmessage struct {
-	m *ExtendingMessage_ExtendingMessageSubmessage
-}
-
-func (m *ExtendingMessage_ExtendingMessageSubmessage) ProtoReflect() protoreflect.Message {
-	return xxx_ExtendingMessage_ExtendingMessageSubmessage{m}
-}
-func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) Type() protoreflect.MessageType {
-	return xxx_Ext_ProtoFile_MessageTypes[7].Type
-}
-func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) KnownFields() protoreflect.KnownFields {
-	return xxx_Ext_ProtoFile_MessageTypes[7].KnownFieldsOf(m.m)
-}
-func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Ext_ProtoFile_MessageTypes[7].UnknownFieldsOf(m.m)
-}
-func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) ProtoMutable() {}
-
-func (m *ExtendingMessage_ExtendingMessageSubmessage) Reset() {
-	*m = ExtendingMessage_ExtendingMessageSubmessage{}
-}
-func (m *ExtendingMessage_ExtendingMessageSubmessage) String() string {
-	return proto.CompactTextString(m)
-}
-func (*ExtendingMessage_ExtendingMessageSubmessage) ProtoMessage() {}
-func (*ExtendingMessage_ExtendingMessageSubmessage) Descriptor() ([]byte, []int) {
-	return fileDescriptor_bf470ef4907b23cb, []int{2, 0}
-}
-
-func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Unmarshal(m, b)
-}
-func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Marshal(b, m, deterministic)
-}
-func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Merge(m, src)
-}
-func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Size() int {
-	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Size(m)
-}
-func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_DiscardUnknown() {
-	xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage proto.InternalMessageInfo
-
 type RepeatedGroup struct {
 	RepeatedXGroup       []string `protobuf:"bytes,319,rep,name=repeated_x_group,json=repeatedXGroup" json:"repeated_x_group,omitempty"`
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -536,15 +405,112 @@
 
 var xxx_messageInfo_MessageSetWireFormatExtension proto.InternalMessageInfo
 
-var E_MessageSetWireFormatExtension_MessageSetExtension = &proto.ExtensionDesc{
-	ExtendedType:  (*base.MessageSetWireFormatMessage)(nil),
-	ExtensionType: (*MessageSetWireFormatExtension)(nil),
-	Field:         100,
-	Name:          "goproto.protoc.extension.ext.MessageSetWireFormatExtension",
-	Tag:           "bytes,100,opt,name=message_set_extension",
-	Filename:      "extensions/ext/ext.proto",
+type Message_M struct {
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
 }
 
+type xxx_Message_M struct{ m *Message_M }
+
+func (m *Message_M) ProtoReflect() protoreflect.Message {
+	return xxx_Message_M{m}
+}
+func (m xxx_Message_M) Type() protoreflect.MessageType {
+	return xxx_Ext_ProtoFile_MessageTypes[6].Type
+}
+func (m xxx_Message_M) KnownFields() protoreflect.KnownFields {
+	return xxx_Ext_ProtoFile_MessageTypes[6].KnownFieldsOf(m.m)
+}
+func (m xxx_Message_M) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Ext_ProtoFile_MessageTypes[6].UnknownFieldsOf(m.m)
+}
+func (m xxx_Message_M) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_Message_M) ProtoMutable() {}
+
+func (m *Message_M) Reset()         { *m = Message_M{} }
+func (m *Message_M) String() string { return proto.CompactTextString(m) }
+func (*Message_M) ProtoMessage()    {}
+func (*Message_M) Descriptor() ([]byte, []int) {
+	return fileDescriptor_bf470ef4907b23cb, []int{0, 0}
+}
+
+func (m *Message_M) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_Message_M.Unmarshal(m, b)
+}
+func (m *Message_M) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_Message_M.Marshal(b, m, deterministic)
+}
+func (m *Message_M) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_Message_M.Merge(m, src)
+}
+func (m *Message_M) XXX_Size() int {
+	return xxx_messageInfo_Message_M.Size(m)
+}
+func (m *Message_M) XXX_DiscardUnknown() {
+	xxx_messageInfo_Message_M.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Message_M proto.InternalMessageInfo
+
+type ExtendingMessage_ExtendingMessageSubmessage struct {
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+type xxx_ExtendingMessage_ExtendingMessageSubmessage struct {
+	m *ExtendingMessage_ExtendingMessageSubmessage
+}
+
+func (m *ExtendingMessage_ExtendingMessageSubmessage) ProtoReflect() protoreflect.Message {
+	return xxx_ExtendingMessage_ExtendingMessageSubmessage{m}
+}
+func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) Type() protoreflect.MessageType {
+	return xxx_Ext_ProtoFile_MessageTypes[7].Type
+}
+func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) KnownFields() protoreflect.KnownFields {
+	return xxx_Ext_ProtoFile_MessageTypes[7].KnownFieldsOf(m.m)
+}
+func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Ext_ProtoFile_MessageTypes[7].UnknownFieldsOf(m.m)
+}
+func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_ExtendingMessage_ExtendingMessageSubmessage) ProtoMutable() {}
+
+func (m *ExtendingMessage_ExtendingMessageSubmessage) Reset() {
+	*m = ExtendingMessage_ExtendingMessageSubmessage{}
+}
+func (m *ExtendingMessage_ExtendingMessageSubmessage) String() string {
+	return proto.CompactTextString(m)
+}
+func (*ExtendingMessage_ExtendingMessageSubmessage) ProtoMessage() {}
+func (*ExtendingMessage_ExtendingMessageSubmessage) Descriptor() ([]byte, []int) {
+	return fileDescriptor_bf470ef4907b23cb, []int{2, 0}
+}
+
+func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Unmarshal(m, b)
+}
+func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Marshal(b, m, deterministic)
+}
+func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Merge(m, src)
+}
+func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_Size() int {
+	return xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.Size(m)
+}
+func (m *ExtendingMessage_ExtendingMessageSubmessage) XXX_DiscardUnknown() {
+	xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage proto.InternalMessageInfo
+
 var E_ExtensionBool = &proto.ExtensionDesc{
 	ExtendedType:  (*base.BaseMessage)(nil),
 	ExtensionType: (*bool)(nil),
@@ -914,19 +880,44 @@
 	Filename:      "extensions/ext/ext.proto",
 }
 
+var E_ExtendingMessage_ExtendingMessageString = &proto.ExtensionDesc{
+	ExtendedType:  (*base.BaseMessage)(nil),
+	ExtensionType: (*string)(nil),
+	Field:         200,
+	Name:          "goproto.protoc.extension.ext.ExtendingMessage.extending_message_string",
+	Tag:           "bytes,200,opt,name=extending_message_string",
+	Filename:      "extensions/ext/ext.proto",
+}
+
+var E_ExtendingMessage_ExtendingMessageSubmessage = &proto.ExtensionDesc{
+	ExtendedType:  (*base.BaseMessage)(nil),
+	ExtensionType: (*ExtendingMessage_ExtendingMessageSubmessage)(nil),
+	Field:         201,
+	Name:          "goproto.protoc.extension.ext.ExtendingMessage.extending_message_submessage",
+	Tag:           "bytes,201,opt,name=extending_message_submessage",
+	Filename:      "extensions/ext/ext.proto",
+}
+
+var E_MessageSetWireFormatExtension_MessageSetExtension = &proto.ExtensionDesc{
+	ExtendedType:  (*base.MessageSetWireFormatMessage)(nil),
+	ExtensionType: (*MessageSetWireFormatExtension)(nil),
+	Field:         100,
+	Name:          "goproto.protoc.extension.ext.MessageSetWireFormatExtension",
+	Tag:           "bytes,100,opt,name=message_set_extension",
+	Filename:      "extensions/ext/ext.proto",
+}
+
 func init() {
+	proto.RegisterFile("extensions/ext/ext.proto", fileDescriptor_bf470ef4907b23cb)
 	proto.RegisterEnum("goproto.protoc.extension.ext.Enum", Enum_name, Enum_value)
 	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.ext.Message")
-	proto.RegisterType((*Message_M)(nil), "goproto.protoc.extension.ext.Message.M")
 	proto.RegisterType((*ExtensionGroup)(nil), "goproto.protoc.extension.ext.ExtensionGroup")
-	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageString)
-	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageSubmessage)
 	proto.RegisterType((*ExtendingMessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage")
-	proto.RegisterType((*ExtendingMessage_ExtendingMessageSubmessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage.ExtendingMessageSubmessage")
 	proto.RegisterType((*RepeatedGroup)(nil), "goproto.protoc.extension.ext.RepeatedGroup")
 	proto.RegisterType((*Extendable)(nil), "goproto.protoc.extension.ext.Extendable")
-	proto.RegisterExtension(E_MessageSetWireFormatExtension_MessageSetExtension)
 	proto.RegisterType((*MessageSetWireFormatExtension)(nil), "goproto.protoc.extension.ext.MessageSetWireFormatExtension")
+	proto.RegisterType((*Message_M)(nil), "goproto.protoc.extension.ext.Message.M")
+	proto.RegisterType((*ExtendingMessage_ExtendingMessageSubmessage)(nil), "goproto.protoc.extension.ext.ExtendingMessage.ExtendingMessageSubmessage")
 	proto.RegisterExtension(E_ExtensionBool)
 	proto.RegisterExtension(E_ExtensionEnum)
 	proto.RegisterExtension(E_ExtensionInt32)
@@ -968,10 +959,11 @@
 	proto.RegisterExtension(E_ExtendableField)
 	proto.RegisterExtension(E_ExtendableStringField)
 	proto.RegisterExtension(E_MessageSetExtension)
+	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageString)
+	proto.RegisterExtension(E_ExtendingMessage_ExtendingMessageSubmessage)
+	proto.RegisterExtension(E_MessageSetWireFormatExtension_MessageSetExtension)
 }
 
-func init() { proto.RegisterFile("extensions/ext/ext.proto", fileDescriptor_bf470ef4907b23cb) }
-
 var fileDescriptor_bf470ef4907b23cb = []byte{
 	// 1120 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x98, 0xcb, 0x6e, 0xdb, 0x46,
diff --git a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
index 3761b44..30e699c 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -4,19 +4,12 @@
 package extra
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -82,11 +75,10 @@
 }
 
 func init() {
+	proto.RegisterFile("extensions/extra/extra.proto", fileDescriptor_496c2a5e9c1e8739)
 	proto.RegisterType((*ExtraMessage)(nil), "goproto.protoc.extension.extra.ExtraMessage")
 }
 
-func init() { proto.RegisterFile("extensions/extra/extra.proto", fileDescriptor_496c2a5e9c1e8739) }
-
 var fileDescriptor_496c2a5e9c1e8739 = []byte{
 	// 149 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xad, 0x28, 0x49,
diff --git a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
index db91063..9055dae 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -4,20 +4,13 @@
 package proto3
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -415,6 +408,7 @@
 }
 
 func init() {
+	proto.RegisterFile("extensions/proto3/ext3.proto", fileDescriptor_3db31bb248c8865e)
 	proto.RegisterEnum("goproto.protoc.extension.proto3.Enum", Enum_name, Enum_value)
 	proto.RegisterType((*Message)(nil), "goproto.protoc.extension.proto3.Message")
 	proto.RegisterExtension(E_ExtensionBool)
@@ -453,8 +447,6 @@
 	proto.RegisterExtension(E_RepeatedExtension_Message)
 }
 
-func init() { proto.RegisterFile("extensions/proto3/ext3.proto", fileDescriptor_3db31bb248c8865e) }
-
 var fileDescriptor_3db31bb248c8865e = []byte{
 	// 758 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x97, 0xdb, 0x4b, 0xdc, 0x5e,
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index 3439cdb..241a8f4 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -4,19 +4,12 @@
 package fieldnames
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -356,12 +349,11 @@
 var xxx_messageInfo_Message_OneofMessageConflict proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("fieldnames/fieldnames.proto", fileDescriptor_6bbe3f70febb9403)
 	proto.RegisterType((*Message)(nil), "goproto.protoc.fieldnames.Message")
 	proto.RegisterType((*Message_OneofMessageConflict)(nil), "goproto.protoc.fieldnames.Message.OneofMessageConflict")
 }
 
-func init() { proto.RegisterFile("fieldnames/fieldnames.proto", fileDescriptor_6bbe3f70febb9403) }
-
 var fileDescriptor_6bbe3f70febb9403 = []byte{
 	// 417 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0x4b, 0x6f, 0xd3, 0x40,
diff --git a/cmd/protoc-gen-go/testdata/import_public/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
index 9b61bb6..5a8d306 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -4,20 +4,13 @@
 package import_public
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	sub "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -140,11 +133,10 @@
 }
 
 func init() {
+	proto.RegisterFile("import_public/a.proto", fileDescriptor_73b7577c95fa6b70)
 	proto.RegisterType((*Public)(nil), "goproto.protoc.import_public.Public")
 }
 
-func init() { proto.RegisterFile("import_public/a.proto", fileDescriptor_73b7577c95fa6b70) }
-
 var fileDescriptor_73b7577c95fa6b70 = []byte{
 	// 202 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/import_public/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
index 5660ffe..1efbbbd 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -4,20 +4,13 @@
 package import_public
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	sub "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -91,11 +84,10 @@
 }
 
 func init() {
+	proto.RegisterFile("import_public/b.proto", fileDescriptor_84995586b3d09710)
 	proto.RegisterType((*Local)(nil), "goproto.protoc.import_public.Local")
 }
 
-func init() { proto.RegisterFile("import_public/b.proto", fileDescriptor_84995586b3d09710) }
-
 var fileDescriptor_84995586b3d09710 = []byte{
 	// 176 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
index b3b4c14..105c7d4 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
@@ -4,7 +4,6 @@
 package sub
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
@@ -12,11 +11,6 @@
 	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -425,6 +419,7 @@
 }
 
 func init() {
+	proto.RegisterFile("import_public/sub/a.proto", fileDescriptor_382f7805394b5c4e)
 	proto.RegisterEnum("goproto.protoc.import_public.sub.E", E_name, E_value)
 	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Subenum", M_Subenum_name, M_Subenum_value)
 	proto.RegisterEnum("goproto.protoc.import_public.sub.M_Submessage_Submessage_Subenum", M_Submessage_Submessage_Subenum_name, M_Submessage_Submessage_Subenum_value)
@@ -433,8 +428,6 @@
 	proto.RegisterExtension(E_ExtensionField)
 }
 
-func init() { proto.RegisterFile("import_public/sub/a.proto", fileDescriptor_382f7805394b5c4e) }
-
 var fileDescriptor_382f7805394b5c4e = []byte{
 	// 402 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcb, 0x6e, 0xd3, 0x40,
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
index 09c349f..6d1d369 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/b.pb.go
@@ -4,19 +4,12 @@
 package sub
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("import_public/sub/b.proto", fileDescriptor_fc66afda3d7c2232)
 	proto.RegisterType((*M2)(nil), "goproto.protoc.import_public.sub.M2")
 }
 
-func init() { proto.RegisterFile("import_public/sub/b.proto", fileDescriptor_fc66afda3d7c2232) }
-
 var fileDescriptor_fc66afda3d7c2232 = []byte{
 	// 129 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
index 7b8803f..5d5b49f 100644
--- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
@@ -4,19 +4,12 @@
 package fmt
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/fmt/m.proto", fileDescriptor_72c126fcd452e392)
 	proto.RegisterType((*M)(nil), "fmt.M")
 }
 
-func init() { proto.RegisterFile("imports/fmt/m.proto", fileDescriptor_72c126fcd452e392) }
-
 var fileDescriptor_72c126fcd452e392 = []byte{
 	// 109 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xce, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
index 34d67e5..fe1b45e 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
@@ -4,19 +4,12 @@
 package test_a_1
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -166,13 +159,12 @@
 }
 
 func init() {
+	proto.RegisterFile("imports/test_a_1/m1.proto", fileDescriptor_c1091de3fa870a14)
 	proto.RegisterEnum("test.a.E1", E1_name, E1_value)
 	proto.RegisterType((*M1)(nil), "test.a.M1")
 	proto.RegisterType((*M1_1)(nil), "test.a.M1_1")
 }
 
-func init() { proto.RegisterFile("imports/test_a_1/m1.proto", fileDescriptor_c1091de3fa870a14) }
-
 var fileDescriptor_c1091de3fa870a14 = []byte{
 	// 165 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
index 04927aa..3ad0232 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
@@ -4,19 +4,12 @@
 package test_a_1
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/test_a_1/m2.proto", fileDescriptor_20cf27515c0d621c)
 	proto.RegisterType((*M2)(nil), "test.a.M2")
 }
 
-func init() { proto.RegisterFile("imports/test_a_1/m2.proto", fileDescriptor_20cf27515c0d621c) }
-
 var fileDescriptor_20cf27515c0d621c = []byte{
 	// 114 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
index 5da2716..856147d 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
@@ -4,19 +4,12 @@
 package test_a_2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M3 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/test_a_2/m3.proto", fileDescriptor_ff9d8f834875c9c5)
 	proto.RegisterType((*M3)(nil), "test.a.M3")
 }
 
-func init() { proto.RegisterFile("imports/test_a_2/m3.proto", fileDescriptor_ff9d8f834875c9c5) }
-
 var fileDescriptor_ff9d8f834875c9c5 = []byte{
 	// 114 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
index e4f4c59..8aa2304 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
@@ -4,19 +4,12 @@
 package test_a_2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M4 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/test_a_2/m4.proto", fileDescriptor_fdd24f82f6c5a786)
 	proto.RegisterType((*M4)(nil), "test.a.M4")
 }
 
-func init() { proto.RegisterFile("imports/test_a_2/m4.proto", fileDescriptor_fdd24f82f6c5a786) }
-
 var fileDescriptor_fdd24f82f6c5a786 = []byte{
 	// 114 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
index 3d5a9b1..99d09a0 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
@@ -4,19 +4,12 @@
 package beta
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M1 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/test_b_1/m1.proto", fileDescriptor_7f49573d035512a8)
 	proto.RegisterType((*M1)(nil), "test.b.part1.M1")
 }
 
-func init() { proto.RegisterFile("imports/test_b_1/m1.proto", fileDescriptor_7f49573d035512a8) }
-
 var fileDescriptor_7f49573d035512a8 = []byte{
 	// 125 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
index 80283f1..70cf5cf 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
@@ -4,19 +4,12 @@
 package beta
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -74,11 +67,10 @@
 var xxx_messageInfo_M2 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("imports/test_b_1/m2.proto", fileDescriptor_a1becddceeb586f2)
 	proto.RegisterType((*M2)(nil), "test.b.part2.M2")
 }
 
-func init() { proto.RegisterFile("imports/test_b_1/m2.proto", fileDescriptor_a1becddceeb586f2) }
-
 var fileDescriptor_a1becddceeb586f2 = []byte{
 	// 125 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
index a75708e..5e1f17c 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
@@ -4,20 +4,13 @@
 package imports
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -83,11 +76,10 @@
 }
 
 func init() {
+	proto.RegisterFile("imports/test_import_a1m1.proto", fileDescriptor_3b904a47327455f3)
 	proto.RegisterType((*A1M1)(nil), "test.A1M1")
 }
 
-func init() { proto.RegisterFile("imports/test_import_a1m1.proto", fileDescriptor_3b904a47327455f3) }
-
 var fileDescriptor_3b904a47327455f3 = []byte{
 	// 149 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
index 58a0669..3afbc97 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
@@ -4,20 +4,13 @@
 package imports
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -83,11 +76,10 @@
 }
 
 func init() {
+	proto.RegisterFile("imports/test_import_a1m2.proto", fileDescriptor_bdb27b114687957d)
 	proto.RegisterType((*A1M2)(nil), "test.A1M2")
 }
 
-func init() { proto.RegisterFile("imports/test_import_a1m2.proto", fileDescriptor_bdb27b114687957d) }
-
 var fileDescriptor_bdb27b114687957d = []byte{
 	// 149 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcb, 0xcc, 0x2d, 0xc8,
diff --git a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
index b7cf7ef..b661d55 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_import_all.pb.go
@@ -4,23 +4,16 @@
 package imports
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
-	fmt1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
+	fmt "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
 	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
 	_ "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2"
 	test_b_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -32,7 +25,7 @@
 	Am2                  *test_a_1.M2 `protobuf:"bytes,2,opt,name=am2,proto3" json:"am2,omitempty"`
 	Bm1                  *test_b_1.M1 `protobuf:"bytes,5,opt,name=bm1,proto3" json:"bm1,omitempty"`
 	Bm2                  *test_b_1.M2 `protobuf:"bytes,6,opt,name=bm2,proto3" json:"bm2,omitempty"`
-	Fmt                  *fmt1.M      `protobuf:"bytes,7,opt,name=fmt,proto3" json:"fmt,omitempty"`
+	Fmt                  *fmt.M       `protobuf:"bytes,7,opt,name=fmt,proto3" json:"fmt,omitempty"`
 	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
 	XXX_unrecognized     []byte       `json:"-"`
 	XXX_sizecache        int32        `json:"-"`
@@ -110,7 +103,7 @@
 	return nil
 }
 
-func (m *All) GetFmt() *fmt1.M {
+func (m *All) GetFmt() *fmt.M {
 	if m != nil {
 		return m.Fmt
 	}
@@ -118,11 +111,10 @@
 }
 
 func init() {
+	proto.RegisterFile("imports/test_import_all.proto", fileDescriptor_324466f0afc16f77)
 	proto.RegisterType((*All)(nil), "test.All")
 }
 
-func init() { proto.RegisterFile("imports/test_import_all.proto", fileDescriptor_324466f0afc16f77) }
-
 var fileDescriptor_324466f0afc16f77 = []byte{
 	// 242 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xcf, 0xb1, 0x4e, 0xc3, 0x30,
@@ -149,7 +141,7 @@
 	xxx_TestImportAll_ProtoFile_MessageDescs[0].Fields[1].MessageType = protoimpl.X.MessageTypeOf((*test_a_1.M2)(nil))
 	xxx_TestImportAll_ProtoFile_MessageDescs[0].Fields[2].MessageType = protoimpl.X.MessageTypeOf((*test_b_1.M1)(nil))
 	xxx_TestImportAll_ProtoFile_MessageDescs[0].Fields[3].MessageType = protoimpl.X.MessageTypeOf((*test_b_1.M2)(nil))
-	xxx_TestImportAll_ProtoFile_MessageDescs[0].Fields[4].MessageType = protoimpl.X.MessageTypeOf((*fmt1.M)(nil))
+	xxx_TestImportAll_ProtoFile_MessageDescs[0].Fields[4].MessageType = protoimpl.X.MessageTypeOf((*fmt.M)(nil))
 	var err error
 	TestImportAll_ProtoFile, err = prototype.NewFile(&xxx_TestImportAll_ProtoFile_FileDesc)
 	if err != nil {
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index 84a54b0..597b860 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -4,19 +4,12 @@
 package nopackage
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -141,12 +134,11 @@
 }
 
 func init() {
+	proto.RegisterFile("nopackage/nopackage.proto", fileDescriptor_f33a1d5d178c43c9)
 	proto.RegisterEnum("Enum", Enum_name, Enum_value)
 	proto.RegisterType((*Message)(nil), "Message")
 }
 
-func init() { proto.RegisterFile("nopackage/nopackage.proto", fileDescriptor_f33a1d5d178c43c9) }
-
 var fileDescriptor_f33a1d5d178c43c9 = []byte{
 	// 130 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xcb, 0x2f, 0x48,
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 67c60a0..e3a39f2 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -4,19 +4,12 @@
 package proto2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -456,6 +449,7 @@
 var xxx_messageInfo_EnumContainerMessage1_EnumContainerMessage2 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("proto2/enum.proto", fileDescriptor_de9f68860d540858)
 	proto.RegisterEnum("goproto.protoc.proto2.EnumType1", EnumType1_name, EnumType1_value)
 	proto.RegisterEnum("goproto.protoc.proto2.EnumType2", EnumType2_name, EnumType2_value)
 	proto.RegisterEnum("goproto.protoc.proto2.EnumContainerMessage1_NestedEnumType1A", EnumContainerMessage1_NestedEnumType1A_name, EnumContainerMessage1_NestedEnumType1A_value)
@@ -466,8 +460,6 @@
 	proto.RegisterType((*EnumContainerMessage1_EnumContainerMessage2)(nil), "goproto.protoc.proto2.EnumContainerMessage1.EnumContainerMessage2")
 }
 
-func init() { proto.RegisterFile("proto2/enum.proto", fileDescriptor_de9f68860d540858) }
-
 var fileDescriptor_de9f68860d540858 = []byte{
 	// 296 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0xd0, 0xc1, 0x4b, 0xfb, 0x30,
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 8c382bf..4f0cbb8 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -4,7 +4,6 @@
 package proto2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
@@ -12,11 +11,6 @@
 	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -248,6 +242,10 @@
 const Default_FieldTestMessage_DefaultString string = "hello,\"world!\"\n"
 
 var Default_FieldTestMessage_DefaultBytes []byte = []byte("hello,Þ­\xbe\xef")
+
+const Default_FieldTestMessage_DefaultZeroString string = ""
+
+var Default_FieldTestMessage_DefaultZeroBytes []byte = []byte("")
 var Default_FieldTestMessage_DefaultFloatNeginf float32 = float32(math.Inf(-1))
 var Default_FieldTestMessage_DefaultFloatPosinf float32 = float32(math.Inf(1))
 var Default_FieldTestMessage_DefaultFloatNan float32 = float32(math.NaN())
@@ -749,14 +747,14 @@
 	if m != nil && m.DefaultZeroString != nil {
 		return *m.DefaultZeroString
 	}
-	return ""
+	return Default_FieldTestMessage_DefaultZeroString
 }
 
 func (m *FieldTestMessage) GetDefaultZeroBytes() []byte {
-	if m != nil {
+	if m != nil && m.DefaultZeroBytes != nil {
 		return m.DefaultZeroBytes
 	}
-	return nil
+	return append([]byte(nil), Default_FieldTestMessage_DefaultZeroBytes...)
 }
 
 func (m *FieldTestMessage) GetDefaultFloatNeginf() float32 {
@@ -1433,6 +1431,7 @@
 var xxx_messageInfo_FieldTestMessage_Message proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("proto2/fields.proto", fileDescriptor_fd8a9d72b841fd68)
 	proto.RegisterEnum("goproto.protoc.proto2.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
 	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto2.FieldTestMessage")
 	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry")
@@ -1445,8 +1444,6 @@
 	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto2.FieldTestMessage.Message")
 }
 
-func init() { proto.RegisterFile("proto2/fields.proto", fileDescriptor_fd8a9d72b841fd68) }
-
 var fileDescriptor_fd8a9d72b841fd68 = []byte{
 	// 1941 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x98, 0x5b, 0x73, 0x23, 0x47,
diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
index 4bc6666..4b6594f 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -4,19 +4,12 @@
 package proto2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -198,13 +191,12 @@
 var xxx_messageInfo_Layer1_Layer2_Layer3 proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("proto2/nested_messages.proto", fileDescriptor_7417ee157699d191)
 	proto.RegisterType((*Layer1)(nil), "goproto.protoc.proto2.Layer1")
 	proto.RegisterType((*Layer1_Layer2)(nil), "goproto.protoc.proto2.Layer1.Layer2")
 	proto.RegisterType((*Layer1_Layer2_Layer3)(nil), "goproto.protoc.proto2.Layer1.Layer2.Layer3")
 }
 
-func init() { proto.RegisterFile("proto2/nested_messages.proto", fileDescriptor_7417ee157699d191) }
-
 var fileDescriptor_7417ee157699d191 = []byte{
 	// 190 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x28, 0xca, 0x2f,
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index e168402..eb5618d 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -4,19 +4,12 @@
 package proto2
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -90,11 +83,10 @@
 }
 
 func init() {
+	proto.RegisterFile("proto2/proto2.proto", fileDescriptor_d756bbe8817c03c1)
 	proto.RegisterType((*Message)(nil), "goproto.protoc.proto2.Message")
 }
 
-func init() { proto.RegisterFile("proto2/proto2.proto", fileDescriptor_d756bbe8817c03c1) }
-
 var fileDescriptor_d756bbe8817c03c1 = []byte{
 	// 152 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x28, 0xca, 0x2f,
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index 97ac497..328a439 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -4,19 +4,12 @@
 package proto3
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -64,11 +57,10 @@
 }
 
 func init() {
+	proto.RegisterFile("proto3/enum.proto", fileDescriptor_b4b9b1e8d161a9a6)
 	proto.RegisterEnum("goproto.protoc.proto3.Enum", Enum_name, Enum_value)
 }
 
-func init() { proto.RegisterFile("proto3/enum.proto", fileDescriptor_b4b9b1e8d161a9a6) }
-
 var fileDescriptor_b4b9b1e8d161a9a6 = []byte{
 	// 144 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x28, 0xca, 0x2f,
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index 0acd32f..2a72ccd 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -4,19 +4,12 @@
 package proto3
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -454,6 +447,7 @@
 var xxx_messageInfo_FieldTestMessage_Message proto.InternalMessageInfo
 
 func init() {
+	proto.RegisterFile("proto3/fields.proto", fileDescriptor_f1e3ea068187307c)
 	proto.RegisterEnum("goproto.protoc.proto3.FieldTestMessage_Enum", FieldTestMessage_Enum_name, FieldTestMessage_Enum_value)
 	proto.RegisterType((*FieldTestMessage)(nil), "goproto.protoc.proto3.FieldTestMessage")
 	proto.RegisterMapType((map[uint64]FieldTestMessage_Enum)(nil), "goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry")
@@ -462,8 +456,6 @@
 	proto.RegisterType((*FieldTestMessage_Message)(nil), "goproto.protoc.proto3.FieldTestMessage.Message")
 }
 
-func init() { proto.RegisterFile("proto3/fields.proto", fileDescriptor_f1e3ea068187307c) }
-
 var fileDescriptor_f1e3ea068187307c = []byte{
 	// 832 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x95, 0xc9, 0x6f, 0xdb, 0x38,
diff --git a/types/descriptor/descriptor.pb.go b/types/descriptor/descriptor.pb.go
index 7fdc6d3..2732983 100644
--- a/types/descriptor/descriptor.pb.go
+++ b/types/descriptor/descriptor.pb.go
@@ -703,117 +703,6 @@
 	return nil
 }
 
-type DescriptorProto_ExtensionRange struct {
-	Start                *int32                 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
-	End                  *int32                 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
-	Options              *ExtensionRangeOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
-	XXX_unrecognized     []byte                 `json:"-"`
-	XXX_sizecache        int32                  `json:"-"`
-}
-
-type xxx_DescriptorProto_ExtensionRange struct {
-	m *DescriptorProto_ExtensionRange
-}
-
-func (m *DescriptorProto_ExtensionRange) ProtoReflect() protoreflect.Message {
-	return xxx_DescriptorProto_ExtensionRange{m}
-}
-func (m xxx_DescriptorProto_ExtensionRange) Type() protoreflect.MessageType {
-	return xxx_Descriptor_ProtoFile_MessageTypes[21].Type
-}
-func (m xxx_DescriptorProto_ExtensionRange) KnownFields() protoreflect.KnownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[21].KnownFieldsOf(m.m)
-}
-func (m xxx_DescriptorProto_ExtensionRange) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[21].UnknownFieldsOf(m.m)
-}
-func (m xxx_DescriptorProto_ExtensionRange) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_DescriptorProto_ExtensionRange) ProtoMutable() {}
-
-func (m *DescriptorProto_ExtensionRange) Reset()         { *m = DescriptorProto_ExtensionRange{} }
-func (m *DescriptorProto_ExtensionRange) String() string { return protoapi.CompactTextString(m) }
-func (*DescriptorProto_ExtensionRange) ProtoMessage()    {}
-func (*DescriptorProto_ExtensionRange) Descriptor() ([]byte, []int) {
-	return fileDescriptor_e5baabe45344a177, []int{2, 0}
-}
-
-func (m *DescriptorProto_ExtensionRange) GetStart() int32 {
-	if m != nil && m.Start != nil {
-		return *m.Start
-	}
-	return 0
-}
-
-func (m *DescriptorProto_ExtensionRange) GetEnd() int32 {
-	if m != nil && m.End != nil {
-		return *m.End
-	}
-	return 0
-}
-
-func (m *DescriptorProto_ExtensionRange) GetOptions() *ExtensionRangeOptions {
-	if m != nil {
-		return m.Options
-	}
-	return nil
-}
-
-// Range of reserved tag numbers. Reserved tag numbers may not be used by
-// fields or extension ranges in the same message. Reserved ranges may
-// not overlap.
-type DescriptorProto_ReservedRange struct {
-	Start                *int32   `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
-	End                  *int32   `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_DescriptorProto_ReservedRange struct {
-	m *DescriptorProto_ReservedRange
-}
-
-func (m *DescriptorProto_ReservedRange) ProtoReflect() protoreflect.Message {
-	return xxx_DescriptorProto_ReservedRange{m}
-}
-func (m xxx_DescriptorProto_ReservedRange) Type() protoreflect.MessageType {
-	return xxx_Descriptor_ProtoFile_MessageTypes[22].Type
-}
-func (m xxx_DescriptorProto_ReservedRange) KnownFields() protoreflect.KnownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[22].KnownFieldsOf(m.m)
-}
-func (m xxx_DescriptorProto_ReservedRange) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[22].UnknownFieldsOf(m.m)
-}
-func (m xxx_DescriptorProto_ReservedRange) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_DescriptorProto_ReservedRange) ProtoMutable() {}
-
-func (m *DescriptorProto_ReservedRange) Reset()         { *m = DescriptorProto_ReservedRange{} }
-func (m *DescriptorProto_ReservedRange) String() string { return protoapi.CompactTextString(m) }
-func (*DescriptorProto_ReservedRange) ProtoMessage()    {}
-func (*DescriptorProto_ReservedRange) Descriptor() ([]byte, []int) {
-	return fileDescriptor_e5baabe45344a177, []int{2, 1}
-}
-
-func (m *DescriptorProto_ReservedRange) GetStart() int32 {
-	if m != nil && m.Start != nil {
-		return *m.Start
-	}
-	return 0
-}
-
-func (m *DescriptorProto_ReservedRange) GetEnd() int32 {
-	if m != nil && m.End != nil {
-		return *m.End
-	}
-	return 0
-}
-
 type ExtensionRangeOptions struct {
 	// The parser stores options it doesn't recognize here. See above.
 	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
@@ -1124,62 +1013,6 @@
 	return nil
 }
 
-// Range of reserved numeric values. Reserved values may not be used by
-// entries in the same enum. Reserved ranges may not overlap.
-//
-// Note that this is distinct from DescriptorProto.ReservedRange in that it
-// is inclusive such that it can appropriately represent the entire int32
-// domain.
-type EnumDescriptorProto_EnumReservedRange struct {
-	Start                *int32   `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
-	End                  *int32   `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_EnumDescriptorProto_EnumReservedRange struct {
-	m *EnumDescriptorProto_EnumReservedRange
-}
-
-func (m *EnumDescriptorProto_EnumReservedRange) ProtoReflect() protoreflect.Message {
-	return xxx_EnumDescriptorProto_EnumReservedRange{m}
-}
-func (m xxx_EnumDescriptorProto_EnumReservedRange) Type() protoreflect.MessageType {
-	return xxx_Descriptor_ProtoFile_MessageTypes[23].Type
-}
-func (m xxx_EnumDescriptorProto_EnumReservedRange) KnownFields() protoreflect.KnownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[23].KnownFieldsOf(m.m)
-}
-func (m xxx_EnumDescriptorProto_EnumReservedRange) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[23].UnknownFieldsOf(m.m)
-}
-func (m xxx_EnumDescriptorProto_EnumReservedRange) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_EnumDescriptorProto_EnumReservedRange) ProtoMutable() {}
-
-func (m *EnumDescriptorProto_EnumReservedRange) Reset()         { *m = EnumDescriptorProto_EnumReservedRange{} }
-func (m *EnumDescriptorProto_EnumReservedRange) String() string { return protoapi.CompactTextString(m) }
-func (*EnumDescriptorProto_EnumReservedRange) ProtoMessage()    {}
-func (*EnumDescriptorProto_EnumReservedRange) Descriptor() ([]byte, []int) {
-	return fileDescriptor_e5baabe45344a177, []int{6, 0}
-}
-
-func (m *EnumDescriptorProto_EnumReservedRange) GetStart() int32 {
-	if m != nil && m.Start != nil {
-		return *m.Start
-	}
-	return 0
-}
-
-func (m *EnumDescriptorProto_EnumReservedRange) GetEnd() int32 {
-	if m != nil && m.End != nil {
-		return *m.End
-	}
-	return 0
-}
-
 // Describes a value within an enum.
 type EnumValueDescriptorProto struct {
 	Name                 *string           `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
@@ -2375,59 +2208,6 @@
 	return ""
 }
 
-// The name of the uninterpreted option.  Each string represents a segment in
-// a dot-separated name.  is_extension is true iff a segment represents an
-// extension (denoted with parentheses in options specs in .proto files).
-// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
-// "foo.(bar.baz).qux".
-type UninterpretedOption_NamePart struct {
-	NamePart             *string  `protobuf:"bytes,1,req,name=name_part,json=namePart" json:"name_part,omitempty"`
-	IsExtension          *bool    `protobuf:"varint,2,req,name=is_extension,json=isExtension" json:"is_extension,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-type xxx_UninterpretedOption_NamePart struct{ m *UninterpretedOption_NamePart }
-
-func (m *UninterpretedOption_NamePart) ProtoReflect() protoreflect.Message {
-	return xxx_UninterpretedOption_NamePart{m}
-}
-func (m xxx_UninterpretedOption_NamePart) Type() protoreflect.MessageType {
-	return xxx_Descriptor_ProtoFile_MessageTypes[24].Type
-}
-func (m xxx_UninterpretedOption_NamePart) KnownFields() protoreflect.KnownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[24].KnownFieldsOf(m.m)
-}
-func (m xxx_UninterpretedOption_NamePart) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[24].UnknownFieldsOf(m.m)
-}
-func (m xxx_UninterpretedOption_NamePart) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_UninterpretedOption_NamePart) ProtoMutable() {}
-
-func (m *UninterpretedOption_NamePart) Reset()         { *m = UninterpretedOption_NamePart{} }
-func (m *UninterpretedOption_NamePart) String() string { return protoapi.CompactTextString(m) }
-func (*UninterpretedOption_NamePart) ProtoMessage()    {}
-func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) {
-	return fileDescriptor_e5baabe45344a177, []int{18, 0}
-}
-
-func (m *UninterpretedOption_NamePart) GetNamePart() string {
-	if m != nil && m.NamePart != nil {
-		return *m.NamePart
-	}
-	return ""
-}
-
-func (m *UninterpretedOption_NamePart) GetIsExtension() bool {
-	if m != nil && m.IsExtension != nil {
-		return *m.IsExtension
-	}
-	return false
-}
-
 // Encapsulates information about the original source file from which a
 // FileDescriptorProto was generated.
 type SourceCodeInfo struct {
@@ -2513,6 +2293,271 @@
 	return nil
 }
 
+// Describes the relationship between generated code and its original source
+// file. A GeneratedCodeInfo message is associated with only one generated
+// source file, but may contain references to different source .proto files.
+type GeneratedCodeInfo struct {
+	// An Annotation connects some span of text in generated code to an element
+	// of its generating .proto file.
+	Annotation           []*GeneratedCodeInfo_Annotation `protobuf:"bytes,1,rep,name=annotation" json:"annotation,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                        `json:"-"`
+	XXX_unrecognized     []byte                          `json:"-"`
+	XXX_sizecache        int32                           `json:"-"`
+}
+
+type xxx_GeneratedCodeInfo struct{ m *GeneratedCodeInfo }
+
+func (m *GeneratedCodeInfo) ProtoReflect() protoreflect.Message {
+	return xxx_GeneratedCodeInfo{m}
+}
+func (m xxx_GeneratedCodeInfo) Type() protoreflect.MessageType {
+	return xxx_Descriptor_ProtoFile_MessageTypes[20].Type
+}
+func (m xxx_GeneratedCodeInfo) KnownFields() protoreflect.KnownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[20].KnownFieldsOf(m.m)
+}
+func (m xxx_GeneratedCodeInfo) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[20].UnknownFieldsOf(m.m)
+}
+func (m xxx_GeneratedCodeInfo) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_GeneratedCodeInfo) ProtoMutable() {}
+
+func (m *GeneratedCodeInfo) Reset()         { *m = GeneratedCodeInfo{} }
+func (m *GeneratedCodeInfo) String() string { return protoapi.CompactTextString(m) }
+func (*GeneratedCodeInfo) ProtoMessage()    {}
+func (*GeneratedCodeInfo) Descriptor() ([]byte, []int) {
+	return fileDescriptor_e5baabe45344a177, []int{20}
+}
+
+func (m *GeneratedCodeInfo) GetAnnotation() []*GeneratedCodeInfo_Annotation {
+	if m != nil {
+		return m.Annotation
+	}
+	return nil
+}
+
+type DescriptorProto_ExtensionRange struct {
+	Start                *int32                 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
+	End                  *int32                 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
+	Options              *ExtensionRangeOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
+	XXX_unrecognized     []byte                 `json:"-"`
+	XXX_sizecache        int32                  `json:"-"`
+}
+
+type xxx_DescriptorProto_ExtensionRange struct {
+	m *DescriptorProto_ExtensionRange
+}
+
+func (m *DescriptorProto_ExtensionRange) ProtoReflect() protoreflect.Message {
+	return xxx_DescriptorProto_ExtensionRange{m}
+}
+func (m xxx_DescriptorProto_ExtensionRange) Type() protoreflect.MessageType {
+	return xxx_Descriptor_ProtoFile_MessageTypes[21].Type
+}
+func (m xxx_DescriptorProto_ExtensionRange) KnownFields() protoreflect.KnownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[21].KnownFieldsOf(m.m)
+}
+func (m xxx_DescriptorProto_ExtensionRange) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[21].UnknownFieldsOf(m.m)
+}
+func (m xxx_DescriptorProto_ExtensionRange) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_DescriptorProto_ExtensionRange) ProtoMutable() {}
+
+func (m *DescriptorProto_ExtensionRange) Reset()         { *m = DescriptorProto_ExtensionRange{} }
+func (m *DescriptorProto_ExtensionRange) String() string { return protoapi.CompactTextString(m) }
+func (*DescriptorProto_ExtensionRange) ProtoMessage()    {}
+func (*DescriptorProto_ExtensionRange) Descriptor() ([]byte, []int) {
+	return fileDescriptor_e5baabe45344a177, []int{2, 0}
+}
+
+func (m *DescriptorProto_ExtensionRange) GetStart() int32 {
+	if m != nil && m.Start != nil {
+		return *m.Start
+	}
+	return 0
+}
+
+func (m *DescriptorProto_ExtensionRange) GetEnd() int32 {
+	if m != nil && m.End != nil {
+		return *m.End
+	}
+	return 0
+}
+
+func (m *DescriptorProto_ExtensionRange) GetOptions() *ExtensionRangeOptions {
+	if m != nil {
+		return m.Options
+	}
+	return nil
+}
+
+// Range of reserved tag numbers. Reserved tag numbers may not be used by
+// fields or extension ranges in the same message. Reserved ranges may
+// not overlap.
+type DescriptorProto_ReservedRange struct {
+	Start                *int32   `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
+	End                  *int32   `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+type xxx_DescriptorProto_ReservedRange struct {
+	m *DescriptorProto_ReservedRange
+}
+
+func (m *DescriptorProto_ReservedRange) ProtoReflect() protoreflect.Message {
+	return xxx_DescriptorProto_ReservedRange{m}
+}
+func (m xxx_DescriptorProto_ReservedRange) Type() protoreflect.MessageType {
+	return xxx_Descriptor_ProtoFile_MessageTypes[22].Type
+}
+func (m xxx_DescriptorProto_ReservedRange) KnownFields() protoreflect.KnownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[22].KnownFieldsOf(m.m)
+}
+func (m xxx_DescriptorProto_ReservedRange) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[22].UnknownFieldsOf(m.m)
+}
+func (m xxx_DescriptorProto_ReservedRange) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_DescriptorProto_ReservedRange) ProtoMutable() {}
+
+func (m *DescriptorProto_ReservedRange) Reset()         { *m = DescriptorProto_ReservedRange{} }
+func (m *DescriptorProto_ReservedRange) String() string { return protoapi.CompactTextString(m) }
+func (*DescriptorProto_ReservedRange) ProtoMessage()    {}
+func (*DescriptorProto_ReservedRange) Descriptor() ([]byte, []int) {
+	return fileDescriptor_e5baabe45344a177, []int{2, 1}
+}
+
+func (m *DescriptorProto_ReservedRange) GetStart() int32 {
+	if m != nil && m.Start != nil {
+		return *m.Start
+	}
+	return 0
+}
+
+func (m *DescriptorProto_ReservedRange) GetEnd() int32 {
+	if m != nil && m.End != nil {
+		return *m.End
+	}
+	return 0
+}
+
+// Range of reserved numeric values. Reserved values may not be used by
+// entries in the same enum. Reserved ranges may not overlap.
+//
+// Note that this is distinct from DescriptorProto.ReservedRange in that it
+// is inclusive such that it can appropriately represent the entire int32
+// domain.
+type EnumDescriptorProto_EnumReservedRange struct {
+	Start                *int32   `protobuf:"varint,1,opt,name=start" json:"start,omitempty"`
+	End                  *int32   `protobuf:"varint,2,opt,name=end" json:"end,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+type xxx_EnumDescriptorProto_EnumReservedRange struct {
+	m *EnumDescriptorProto_EnumReservedRange
+}
+
+func (m *EnumDescriptorProto_EnumReservedRange) ProtoReflect() protoreflect.Message {
+	return xxx_EnumDescriptorProto_EnumReservedRange{m}
+}
+func (m xxx_EnumDescriptorProto_EnumReservedRange) Type() protoreflect.MessageType {
+	return xxx_Descriptor_ProtoFile_MessageTypes[23].Type
+}
+func (m xxx_EnumDescriptorProto_EnumReservedRange) KnownFields() protoreflect.KnownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[23].KnownFieldsOf(m.m)
+}
+func (m xxx_EnumDescriptorProto_EnumReservedRange) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[23].UnknownFieldsOf(m.m)
+}
+func (m xxx_EnumDescriptorProto_EnumReservedRange) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_EnumDescriptorProto_EnumReservedRange) ProtoMutable() {}
+
+func (m *EnumDescriptorProto_EnumReservedRange) Reset()         { *m = EnumDescriptorProto_EnumReservedRange{} }
+func (m *EnumDescriptorProto_EnumReservedRange) String() string { return protoapi.CompactTextString(m) }
+func (*EnumDescriptorProto_EnumReservedRange) ProtoMessage()    {}
+func (*EnumDescriptorProto_EnumReservedRange) Descriptor() ([]byte, []int) {
+	return fileDescriptor_e5baabe45344a177, []int{6, 0}
+}
+
+func (m *EnumDescriptorProto_EnumReservedRange) GetStart() int32 {
+	if m != nil && m.Start != nil {
+		return *m.Start
+	}
+	return 0
+}
+
+func (m *EnumDescriptorProto_EnumReservedRange) GetEnd() int32 {
+	if m != nil && m.End != nil {
+		return *m.End
+	}
+	return 0
+}
+
+// The name of the uninterpreted option.  Each string represents a segment in
+// a dot-separated name.  is_extension is true iff a segment represents an
+// extension (denoted with parentheses in options specs in .proto files).
+// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
+// "foo.(bar.baz).qux".
+type UninterpretedOption_NamePart struct {
+	NamePart             *string  `protobuf:"bytes,1,req,name=name_part,json=namePart" json:"name_part,omitempty"`
+	IsExtension          *bool    `protobuf:"varint,2,req,name=is_extension,json=isExtension" json:"is_extension,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+type xxx_UninterpretedOption_NamePart struct{ m *UninterpretedOption_NamePart }
+
+func (m *UninterpretedOption_NamePart) ProtoReflect() protoreflect.Message {
+	return xxx_UninterpretedOption_NamePart{m}
+}
+func (m xxx_UninterpretedOption_NamePart) Type() protoreflect.MessageType {
+	return xxx_Descriptor_ProtoFile_MessageTypes[24].Type
+}
+func (m xxx_UninterpretedOption_NamePart) KnownFields() protoreflect.KnownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[24].KnownFieldsOf(m.m)
+}
+func (m xxx_UninterpretedOption_NamePart) UnknownFields() protoreflect.UnknownFields {
+	return xxx_Descriptor_ProtoFile_MessageTypes[24].UnknownFieldsOf(m.m)
+}
+func (m xxx_UninterpretedOption_NamePart) Interface() protoreflect.ProtoMessage {
+	return m.m
+}
+func (m xxx_UninterpretedOption_NamePart) ProtoMutable() {}
+
+func (m *UninterpretedOption_NamePart) Reset()         { *m = UninterpretedOption_NamePart{} }
+func (m *UninterpretedOption_NamePart) String() string { return protoapi.CompactTextString(m) }
+func (*UninterpretedOption_NamePart) ProtoMessage()    {}
+func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) {
+	return fileDescriptor_e5baabe45344a177, []int{18, 0}
+}
+
+func (m *UninterpretedOption_NamePart) GetNamePart() string {
+	if m != nil && m.NamePart != nil {
+		return *m.NamePart
+	}
+	return ""
+}
+
+func (m *UninterpretedOption_NamePart) GetIsExtension() bool {
+	if m != nil && m.IsExtension != nil {
+		return *m.IsExtension
+	}
+	return false
+}
+
 type SourceCodeInfo_Location struct {
 	// Identifies which part of the FileDescriptorProto was defined at this
 	// location.
@@ -2660,51 +2705,6 @@
 	return nil
 }
 
-// Describes the relationship between generated code and its original source
-// file. A GeneratedCodeInfo message is associated with only one generated
-// source file, but may contain references to different source .proto files.
-type GeneratedCodeInfo struct {
-	// An Annotation connects some span of text in generated code to an element
-	// of its generating .proto file.
-	Annotation           []*GeneratedCodeInfo_Annotation `protobuf:"bytes,1,rep,name=annotation" json:"annotation,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}                        `json:"-"`
-	XXX_unrecognized     []byte                          `json:"-"`
-	XXX_sizecache        int32                           `json:"-"`
-}
-
-type xxx_GeneratedCodeInfo struct{ m *GeneratedCodeInfo }
-
-func (m *GeneratedCodeInfo) ProtoReflect() protoreflect.Message {
-	return xxx_GeneratedCodeInfo{m}
-}
-func (m xxx_GeneratedCodeInfo) Type() protoreflect.MessageType {
-	return xxx_Descriptor_ProtoFile_MessageTypes[20].Type
-}
-func (m xxx_GeneratedCodeInfo) KnownFields() protoreflect.KnownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[20].KnownFieldsOf(m.m)
-}
-func (m xxx_GeneratedCodeInfo) UnknownFields() protoreflect.UnknownFields {
-	return xxx_Descriptor_ProtoFile_MessageTypes[20].UnknownFieldsOf(m.m)
-}
-func (m xxx_GeneratedCodeInfo) Interface() protoreflect.ProtoMessage {
-	return m.m
-}
-func (m xxx_GeneratedCodeInfo) ProtoMutable() {}
-
-func (m *GeneratedCodeInfo) Reset()         { *m = GeneratedCodeInfo{} }
-func (m *GeneratedCodeInfo) String() string { return protoapi.CompactTextString(m) }
-func (*GeneratedCodeInfo) ProtoMessage()    {}
-func (*GeneratedCodeInfo) Descriptor() ([]byte, []int) {
-	return fileDescriptor_e5baabe45344a177, []int{20}
-}
-
-func (m *GeneratedCodeInfo) GetAnnotation() []*GeneratedCodeInfo_Annotation {
-	if m != nil {
-		return m.Annotation
-	}
-	return nil
-}
-
 type GeneratedCodeInfo_Annotation struct {
 	// Identifies the element in the original source .proto file. This field
 	// is formatted the same as SourceCodeInfo.Location.path.
@@ -2778,6 +2778,7 @@
 }
 
 func init() {
+	protoapi.RegisterFile("google/protobuf/descriptor.proto", fileDescriptor_e5baabe45344a177)
 	protoapi.RegisterEnum("google.protobuf.FieldDescriptorProto_Type", FieldDescriptorProto_Type_name, FieldDescriptorProto_Type_value)
 	protoapi.RegisterEnum("google.protobuf.FieldDescriptorProto_Label", FieldDescriptorProto_Label_name, FieldDescriptorProto_Label_value)
 	protoapi.RegisterEnum("google.protobuf.FileOptions_OptimizeMode", FileOptions_OptimizeMode_name, FileOptions_OptimizeMode_value)
@@ -2787,13 +2788,10 @@
 	protoapi.RegisterType((*FileDescriptorSet)(nil), "google.protobuf.FileDescriptorSet")
 	protoapi.RegisterType((*FileDescriptorProto)(nil), "google.protobuf.FileDescriptorProto")
 	protoapi.RegisterType((*DescriptorProto)(nil), "google.protobuf.DescriptorProto")
-	protoapi.RegisterType((*DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange")
-	protoapi.RegisterType((*DescriptorProto_ReservedRange)(nil), "google.protobuf.DescriptorProto.ReservedRange")
 	protoapi.RegisterType((*ExtensionRangeOptions)(nil), "google.protobuf.ExtensionRangeOptions")
 	protoapi.RegisterType((*FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto")
 	protoapi.RegisterType((*OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto")
 	protoapi.RegisterType((*EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto")
-	protoapi.RegisterType((*EnumDescriptorProto_EnumReservedRange)(nil), "google.protobuf.EnumDescriptorProto.EnumReservedRange")
 	protoapi.RegisterType((*EnumValueDescriptorProto)(nil), "google.protobuf.EnumValueDescriptorProto")
 	protoapi.RegisterType((*ServiceDescriptorProto)(nil), "google.protobuf.ServiceDescriptorProto")
 	protoapi.RegisterType((*MethodDescriptorProto)(nil), "google.protobuf.MethodDescriptorProto")
@@ -2806,17 +2804,16 @@
 	protoapi.RegisterType((*ServiceOptions)(nil), "google.protobuf.ServiceOptions")
 	protoapi.RegisterType((*MethodOptions)(nil), "google.protobuf.MethodOptions")
 	protoapi.RegisterType((*UninterpretedOption)(nil), "google.protobuf.UninterpretedOption")
-	protoapi.RegisterType((*UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart")
 	protoapi.RegisterType((*SourceCodeInfo)(nil), "google.protobuf.SourceCodeInfo")
-	protoapi.RegisterType((*SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location")
 	protoapi.RegisterType((*GeneratedCodeInfo)(nil), "google.protobuf.GeneratedCodeInfo")
+	protoapi.RegisterType((*DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange")
+	protoapi.RegisterType((*DescriptorProto_ReservedRange)(nil), "google.protobuf.DescriptorProto.ReservedRange")
+	protoapi.RegisterType((*EnumDescriptorProto_EnumReservedRange)(nil), "google.protobuf.EnumDescriptorProto.EnumReservedRange")
+	protoapi.RegisterType((*UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart")
+	protoapi.RegisterType((*SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location")
 	protoapi.RegisterType((*GeneratedCodeInfo_Annotation)(nil), "google.protobuf.GeneratedCodeInfo.Annotation")
 }
 
-func init() {
-	protoapi.RegisterFile("google/protobuf/descriptor.proto", fileDescriptor_e5baabe45344a177)
-}
-
 var fileDescriptor_e5baabe45344a177 = []byte{
 	// 2589 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0xdd, 0x6e, 0x1b, 0xc7,
diff --git a/types/plugin/plugin.pb.go b/types/plugin/plugin.pb.go
index 0beb617..4cffd71 100644
--- a/types/plugin/plugin.pb.go
+++ b/types/plugin/plugin.pb.go
@@ -4,20 +4,13 @@
 package plugin_proto
 
 import (
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	prototype "github.com/golang/protobuf/v2/reflect/prototype"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	descriptor "github.com/golang/protobuf/v2/types/descriptor"
-	math "math"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
 // This is a compile-time assertion to ensure that this generated file
 // is compatible with the proto package it is being compiled against.
 // A compilation error at this line likely means your copy of the
@@ -411,16 +404,13 @@
 }
 
 func init() {
+	proto.RegisterFile("google/protobuf/compiler/plugin.proto", fileDescriptor_3562add825dafed5)
 	proto.RegisterType((*Version)(nil), "google.protobuf.compiler.Version")
 	proto.RegisterType((*CodeGeneratorRequest)(nil), "google.protobuf.compiler.CodeGeneratorRequest")
 	proto.RegisterType((*CodeGeneratorResponse)(nil), "google.protobuf.compiler.CodeGeneratorResponse")
 	proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File")
 }
 
-func init() {
-	proto.RegisterFile("google/protobuf/compiler/plugin.proto", fileDescriptor_3562add825dafed5)
-}
-
 var fileDescriptor_3562add825dafed5 = []byte{
 	// 416 bytes of a gzipped FileDescriptorProto
 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x6a, 0xd5, 0x40,