internal/filedesc, internal/filetype: initial commit

The internal/fileinit package is split apart into two packages:
* internal/filedesc constructs descriptors from the raw proto.
It is very similar to the previous internal/fileinit package.
* internal/filetype wraps descriptors with Go type information

Overview:
* The internal/fileinit package will be deleted in a future CL.
It is kept around since the v1 repo currently depends on it.
* The internal/prototype package is deleted. All former usages of it
are now using internal/filedesc instead. Most significantly,
the reflect/protodesc package was almost entirely re-written.
* The internal/impl package drops support for messages that do not
have a Descriptor method (pre-2016). This removes a significant amount
of technical debt.
filedesc.Builder to parse raw descriptors.
* The internal/encoding/defval package now handles enum values by name.

Change-Id: I3957bcc8588a70470fd6c7de1122216b80615ab7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/182360
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 33c525e..8a1a6a4 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
 )
@@ -57,6 +56,11 @@
 var file_grpc_deprecation_proto_depIdxs = []int32{
 	0, // goproto.protoc.grpc.DeprecatedService.DeprecatedCall:input_type -> goproto.protoc.grpc.Request
 	1, // goproto.protoc.grpc.DeprecatedService.DeprecatedCall:output_type -> goproto.protoc.grpc.Response
+	1, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_grpc_deprecation_proto_init() }
@@ -65,13 +69,18 @@
 		return
 	}
 	file_grpc_grpc_proto_init()
-	File_grpc_deprecation_proto = protoimpl.FileBuilder{
-		RawDescriptor:     file_grpc_deprecation_proto_rawDesc,
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_grpc_deprecation_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   0,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
 		GoTypes:           file_grpc_deprecation_proto_goTypes,
 		DependencyIndexes: file_grpc_deprecation_proto_depIdxs,
-		FilesRegistry:     protoregistry.GlobalFiles,
-		TypesRegistry:     protoregistry.GlobalTypes,
-	}.Init()
+	}.Build()
+	File_grpc_deprecation_proto = out.File
 	file_grpc_deprecation_proto_rawDesc = nil
 	file_grpc_deprecation_proto_goTypes = nil
 	file_grpc_deprecation_proto_depIdxs = nil
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 8a047bb..77bcc61 100644
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
+++ b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -129,13 +128,18 @@
 }
 var file_grpc_grpc_proto_depIdxs = []int32{
 	0, // goproto.protoc.grpc.test_service.unary_call:input_type -> goproto.protoc.grpc.Request
-	1, // goproto.protoc.grpc.test_service.unary_call:output_type -> goproto.protoc.grpc.Response
 	0, // goproto.protoc.grpc.test_service.downstream_call:input_type -> goproto.protoc.grpc.Request
-	1, // goproto.protoc.grpc.test_service.downstream_call:output_type -> goproto.protoc.grpc.Response
 	0, // goproto.protoc.grpc.test_service.upstream_call:input_type -> goproto.protoc.grpc.Request
-	1, // goproto.protoc.grpc.test_service.upstream_call:output_type -> goproto.protoc.grpc.Response
 	0, // goproto.protoc.grpc.test_service.bidi_call:input_type -> goproto.protoc.grpc.Request
+	1, // goproto.protoc.grpc.test_service.unary_call:output_type -> goproto.protoc.grpc.Response
+	1, // goproto.protoc.grpc.test_service.downstream_call:output_type -> goproto.protoc.grpc.Response
+	1, // goproto.protoc.grpc.test_service.upstream_call:output_type -> goproto.protoc.grpc.Response
 	1, // goproto.protoc.grpc.test_service.bidi_call:output_type -> goproto.protoc.grpc.Response
+	4, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_grpc_grpc_proto_init() }
@@ -143,14 +147,19 @@
 	if File_grpc_grpc_proto != nil {
 		return
 	}
-	File_grpc_grpc_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_grpc_grpc_proto_rawDesc,
-		GoTypes:            file_grpc_grpc_proto_goTypes,
-		DependencyIndexes:  file_grpc_grpc_proto_depIdxs,
-		MessageOutputTypes: file_grpc_grpc_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_grpc_grpc_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_grpc_grpc_proto_goTypes,
+		DependencyIndexes: file_grpc_grpc_proto_depIdxs,
+		MessageInfos:      file_grpc_grpc_proto_msgTypes,
+	}.Build()
+	File_grpc_grpc_proto = out.File
 	file_grpc_grpc_proto_rawDesc = nil
 	file_grpc_grpc_proto_goTypes = nil
 	file_grpc_grpc_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index a17af06..b3556a4 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -44,6 +44,7 @@
 	protoimplPackage     = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoimpl")
 	protoreflectPackage  = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoreflect")
 	protoregistryPackage = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoregistry")
+	prototypePackage     = protogen.GoImportPath("google.golang.org/protobuf/reflect/prototype")
 )
 
 type fileInfo struct {
@@ -65,7 +66,7 @@
 	}
 
 	// Collect all enums, messages, and extensions in "flattened ordering".
-	// See fileinit.FileBuilder.
+	// See filetype.TypeBuilder.
 	f.allEnums = append(f.allEnums, f.Enums...)
 	f.allMessages = append(f.allMessages, f.Messages...)
 	f.allExtensions = append(f.allExtensions, f.Extensions...)
@@ -625,7 +626,7 @@
 		return
 	}
 
-	g.P("var ", extDecsVarName(f), " = []", protoifacePackage.Ident("ExtensionDescV1"), "{")
+	g.P("var ", extDescsVarName(f), " = []", protoifacePackage.Ident("ExtensionDescV1"), "{")
 	for _, extension := range f.allExtensions {
 		// Special case for proto2 message sets: If this extension is extending
 		// proto2.bridge.MessageSet, and its final name component is "message_set_extension",
@@ -668,7 +669,7 @@
 		}
 		fieldName := string(ed.Name())
 		g.P("// extend ", targetName, " { ", ed.Cardinality().String(), " ", typeName, " ", fieldName, " = ", ed.Number(), "; }")
-		g.P(extensionVar(f.File, extension), " = &", extDecsVarName(f), "[", i, "]")
+		g.P(extensionVar(f.File, extension), " = &", extDescsVarName(f), "[", i, "]")
 		g.P()
 	}
 	g.P(")")
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 53d7c96..c58a3ef 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -25,7 +25,7 @@
 
 	genFileDescriptor(gen, g, f)
 	if len(f.allEnums) > 0 {
-		g.P("var ", enumTypesVarName(f), " = make([]", protoreflectPackage.Ident("EnumType"), ",", len(f.allEnums), ")")
+		g.P("var ", enumTypesVarName(f), " = make([]", prototypePackage.Ident("Enum"), ",", len(f.allEnums), ")")
 	}
 	if len(f.allMessages) > 0 {
 		g.P("var ", messageTypesVarName(f), " = make([]", protoimplPackage.Ident("MessageInfo"), ",", len(f.allMessages), ")")
@@ -73,17 +73,16 @@
 		}
 	}
 
-	// This ordering is significant. See protoimpl.FileBuilder.GoTypes.
+	// This ordering is significant.
+	// See filetype.TypeBuilder.DependencyIndexes.
+	var depOffsets []string
 	for _, enum := range f.allEnums {
 		genEnum(enum, "")
 	}
 	for _, message := range f.allMessages {
 		genMessage(message, "")
 	}
-	for _, extension := range f.allExtensions {
-		source := string(extension.Desc.FullName())
-		genMessage(extension.Extendee, source+":extendee")
-	}
+	depOffsets = append(depOffsets, fmt.Sprintf("%d, // starting offset of field type_name sub-list", len(depIdxs)))
 	for _, message := range f.allMessages {
 		for _, field := range message.Fields {
 			if field.Desc.IsWeak() {
@@ -94,18 +93,34 @@
 			genMessage(field.Message, source+":type_name")
 		}
 	}
+	depOffsets = append(depOffsets, fmt.Sprintf("%d, // starting offset of extension extendee sub-list", len(depIdxs)))
+	for _, extension := range f.allExtensions {
+		source := string(extension.Desc.FullName())
+		genMessage(extension.Extendee, source+":extendee")
+	}
+	depOffsets = append(depOffsets, fmt.Sprintf("%d, // starting offset of extension type_name sub-list", len(depIdxs)))
 	for _, extension := range f.allExtensions {
 		source := string(extension.Desc.FullName())
 		genEnum(extension.Enum, source+":type_name")
 		genMessage(extension.Message, source+":type_name")
 	}
+	depOffsets = append(depOffsets, fmt.Sprintf("%d, // starting offset of method input_type sub-list", len(depIdxs)))
 	for _, service := range f.Services {
 		for _, method := range service.Methods {
 			source := string(method.Desc.FullName())
 			genMessage(method.Input, source+":input_type")
+		}
+	}
+	depOffsets = append(depOffsets, fmt.Sprintf("%d, // starting offset of method output_type sub-list", len(depIdxs)))
+	for _, service := range f.Services {
+		for _, method := range service.Methods {
+			source := string(method.Desc.FullName())
 			genMessage(method.Output, source+":output_type")
 		}
 	}
+	for i := len(depOffsets) - 1; i >= 0; i-- {
+		depIdxs = append(depIdxs, depOffsets[i])
+	}
 	if len(depIdxs) > math.MaxInt32 {
 		panic("too many dependencies") // sanity check
 	}
@@ -140,29 +155,27 @@
 		g.P(initFuncName(impFile), "()")
 	}
 
-	if len(f.allExtensions) > 0 {
-		g.P("extensionTypes := make([]", protoreflectPackage.Ident("ExtensionType"), ",", len(f.allExtensions), ")")
-	}
-
-	g.P(f.GoDescriptorIdent, " = ", protoimplPackage.Ident("FileBuilder"), "{")
+	g.P("out := ", protoimplPackage.Ident("TypeBuilder"), "{")
+	g.P("File: ", protoimplPackage.Ident("DescBuilder"), "{")
 	g.P("RawDescriptor: ", rawDescVarName(f), ",")
+	g.P("NumEnums: ", len(f.allEnums), ",")
+	g.P("NumMessages: ", len(f.allMessages), ",")
+	g.P("NumExtensions: ", len(f.allExtensions), ",")
+	g.P("NumServices: ", len(f.Services), ",")
+	g.P("},")
 	g.P("GoTypes: ", goTypesVarName(f), ",")
 	g.P("DependencyIndexes: ", depIdxsVarName(f), ",")
-	if len(f.allExtensions) > 0 {
-		g.P("LegacyExtensions: ", extDecsVarName(f), ",")
-	}
-	if len(f.allEnums) > 0 {
-		g.P("EnumOutputTypes: ", enumTypesVarName(f), ",")
-	}
 	if len(f.allMessages) > 0 {
-		g.P("MessageOutputTypes: ", messageTypesVarName(f), ",")
+		g.P("MessageInfos: ", messageTypesVarName(f), ",")
 	}
 	if len(f.allExtensions) > 0 {
-		g.P("ExtensionOutputTypes: extensionTypes,")
+		g.P("LegacyExtensions: ", extDescsVarName(f), ",")
 	}
-	g.P("FilesRegistry: ", protoregistryPackage.Ident("GlobalFiles"), ",")
-	g.P("TypesRegistry: ", protoregistryPackage.Ident("GlobalTypes"), ",")
-	g.P("}.Init()")
+	g.P("}.Build()")
+	g.P(f.GoDescriptorIdent, " = out.File")
+	if len(f.allEnums) > 0 {
+		g.P(enumTypesVarName(f), " = out.Enums")
+	}
 
 	// Set inputs to nil to allow GC to reclaim resources.
 	g.P(rawDescVarName(f), " = nil")
@@ -235,7 +248,7 @@
 
 	// Descriptor method.
 	g.P("func (", enum.GoIdent, ") Descriptor() ", protoreflectPackage.Ident("EnumDescriptor"), " {")
-	g.P("return ", typesVar, "[", idx, "].Descriptor()")
+	g.P("return ", typesVar, "[", idx, "].EnumDescriptor")
 	g.P("}")
 	g.P()
 
@@ -281,7 +294,7 @@
 func messageTypesVarName(f *fileInfo) string {
 	return fileVarName(f.File, "msgTypes")
 }
-func extDecsVarName(f *fileInfo) string {
+func extDescsVarName(f *fileInfo) string {
 	return fileVarName(f.File, "extDescs")
 }
 func initFuncName(f *protogen.File) string {
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index 1759e76..e81a04f 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -45,7 +45,7 @@
 }
 
 func (AnnotationsTestEnum) Descriptor() protoreflect.EnumDescriptor {
-	return file_annotations_annotations_proto_enumTypes[0].Descriptor()
+	return file_annotations_annotations_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x AnnotationsTestEnum) Number() protoreflect.EnumNumber {
@@ -138,28 +138,39 @@
 	return file_annotations_annotations_proto_rawDescData
 }
 
-var file_annotations_annotations_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_annotations_annotations_proto_enumTypes = make([]prototype.Enum, 1)
 var file_annotations_annotations_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
 var file_annotations_annotations_proto_goTypes = []interface{}{
 	(AnnotationsTestEnum)(0),       // 0: goproto.protoc.annotations.AnnotationsTestEnum
 	(*AnnotationsTestMessage)(nil), // 1: goproto.protoc.annotations.AnnotationsTestMessage
 }
-var file_annotations_annotations_proto_depIdxs = []int32{}
+var file_annotations_annotations_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_annotations_annotations_proto_init() }
 func file_annotations_annotations_proto_init() {
 	if File_annotations_annotations_proto != nil {
 		return
 	}
-	File_annotations_annotations_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_annotations_annotations_proto_rawDesc,
-		GoTypes:            file_annotations_annotations_proto_goTypes,
-		DependencyIndexes:  file_annotations_annotations_proto_depIdxs,
-		EnumOutputTypes:    file_annotations_annotations_proto_enumTypes,
-		MessageOutputTypes: file_annotations_annotations_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_annotations_annotations_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_annotations_annotations_proto_goTypes,
+		DependencyIndexes: file_annotations_annotations_proto_depIdxs,
+		MessageInfos:      file_annotations_annotations_proto_msgTypes,
+	}.Build()
+	File_annotations_annotations_proto = out.File
+	file_annotations_annotations_proto_enumTypes = out.Enums
 	file_annotations_annotations_proto_rawDesc = nil
 	file_annotations_annotations_proto_goTypes = nil
 	file_annotations_annotations_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta
index 1a979ed..a70d989 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go.meta
@@ -1 +1 @@
-annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:639 end:658} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:675 end:722} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1947 end:1969} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:1980 end:2000} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:3021 end:3044}
\ No newline at end of file
+annotation:{path:5 path:0 source_file:"annotations/annotations.proto" begin:631 end:650} annotation:{path:5 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:667 end:714} annotation:{path:4 path:0 source_file:"annotations/annotations.proto" begin:1941 end:1963} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:1974 end:1994} annotation:{path:4 path:0 path:2 path:0 source_file:"annotations/annotations.proto" begin:3015 end:3038}
\ No newline at end of file
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index da5aabe..6cdb147 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -7,7 +7,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -289,21 +288,32 @@
 	(*Message2_Message2A)(nil), // 4: goproto.protoc.comments.Message2.Message2A
 	(*Message2_Message2B)(nil), // 5: goproto.protoc.comments.Message2.Message2B
 }
-var file_comments_comments_proto_depIdxs = []int32{}
+var file_comments_comments_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_comments_comments_proto_init() }
 func file_comments_comments_proto_init() {
 	if File_comments_comments_proto != nil {
 		return
 	}
-	File_comments_comments_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_comments_comments_proto_rawDesc,
-		GoTypes:            file_comments_comments_proto_goTypes,
-		DependencyIndexes:  file_comments_comments_proto_depIdxs,
-		MessageOutputTypes: file_comments_comments_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_comments_comments_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   6,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_comments_comments_proto_goTypes,
+		DependencyIndexes: file_comments_comments_proto_depIdxs,
+		MessageInfos:      file_comments_comments_proto_msgTypes,
+	}.Build()
+	File_comments_comments_proto = out.File
 	file_comments_comments_proto_rawDesc = nil
 	file_comments_comments_proto_goTypes = nil
 	file_comments_comments_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index b19b6d0..22db118 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -44,7 +44,7 @@
 }
 
 func (DeprecatedEnum) Descriptor() protoreflect.EnumDescriptor {
-	return file_comments_deprecated_proto_enumTypes[0].Descriptor()
+	return file_comments_deprecated_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x DeprecatedEnum) Number() protoreflect.EnumNumber {
@@ -128,28 +128,39 @@
 	return file_comments_deprecated_proto_rawDescData
 }
 
-var file_comments_deprecated_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_comments_deprecated_proto_enumTypes = make([]prototype.Enum, 1)
 var file_comments_deprecated_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
 var file_comments_deprecated_proto_goTypes = []interface{}{
 	(DeprecatedEnum)(0),       // 0: goproto.protoc.comments.DeprecatedEnum
 	(*DeprecatedMessage)(nil), // 1: goproto.protoc.comments.DeprecatedMessage
 }
-var file_comments_deprecated_proto_depIdxs = []int32{}
+var file_comments_deprecated_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_comments_deprecated_proto_init() }
 func file_comments_deprecated_proto_init() {
 	if File_comments_deprecated_proto != nil {
 		return
 	}
-	File_comments_deprecated_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_comments_deprecated_proto_rawDesc,
-		GoTypes:            file_comments_deprecated_proto_goTypes,
-		DependencyIndexes:  file_comments_deprecated_proto_depIdxs,
-		EnumOutputTypes:    file_comments_deprecated_proto_enumTypes,
-		MessageOutputTypes: file_comments_deprecated_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_comments_deprecated_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_comments_deprecated_proto_goTypes,
+		DependencyIndexes: file_comments_deprecated_proto_depIdxs,
+		MessageInfos:      file_comments_deprecated_proto_msgTypes,
+	}.Build()
+	File_comments_deprecated_proto = out.File
+	file_comments_deprecated_proto_enumTypes = out.Enums
 	file_comments_deprecated_proto_rawDesc = nil
 	file_comments_deprecated_proto_goTypes = nil
 	file_comments_deprecated_proto_depIdxs = nil
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 1e74be1..4364047 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -142,21 +141,32 @@
 	(*BaseMessage)(nil),                 // 0: goproto.protoc.extension.base.BaseMessage
 	(*MessageSetWireFormatMessage)(nil), // 1: goproto.protoc.extension.base.MessageSetWireFormatMessage
 }
-var file_extensions_base_base_proto_depIdxs = []int32{}
+var file_extensions_base_base_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_extensions_base_base_proto_init() }
 func file_extensions_base_base_proto_init() {
 	if File_extensions_base_base_proto != nil {
 		return
 	}
-	File_extensions_base_base_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_extensions_base_base_proto_rawDesc,
-		GoTypes:            file_extensions_base_base_proto_goTypes,
-		DependencyIndexes:  file_extensions_base_base_proto_depIdxs,
-		MessageOutputTypes: file_extensions_base_base_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_extensions_base_base_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_extensions_base_base_proto_goTypes,
+		DependencyIndexes: file_extensions_base_base_proto_depIdxs,
+		MessageInfos:      file_extensions_base_base_proto_msgTypes,
+	}.Build()
+	File_extensions_base_base_proto = out.File
 	file_extensions_base_base_proto_rawDesc = nil
 	file_extensions_base_base_proto_goTypes = nil
 	file_extensions_base_base_proto_depIdxs = nil
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 3d2627f..167390f 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -7,7 +7,7 @@
 	base "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/extensions/base"
 	extra "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/extensions/extra"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -47,7 +47,7 @@
 }
 
 func (Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_extensions_ext_ext_proto_enumTypes[0].Descriptor()
+	return file_extensions_ext_ext_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x Enum) Number() protoreflect.EnumNumber {
@@ -1155,7 +1155,7 @@
 	return file_extensions_ext_ext_proto_rawDescData
 }
 
-var file_extensions_ext_ext_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_extensions_ext_ext_proto_enumTypes = make([]prototype.Enum, 1)
 var file_extensions_ext_ext_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
 var file_extensions_ext_ext_proto_goTypes = []interface{}{
 	(Enum)(0),                             // 0: goproto.protoc.extension.ext.Enum
@@ -1228,6 +1228,11 @@
 	6,  // goproto.protoc.extension.ext.message_set_extension:type_name -> goproto.protoc.extension.ext.MessageSetWireFormatExtension
 	8,  // goproto.protoc.extension.ext.ExtendingMessage.extending_message_submessage:type_name -> goproto.protoc.extension.ext.ExtendingMessage.ExtendingMessageSubmessage
 	6,  // goproto.protoc.extension.ext.MessageSetWireFormatExtension.message_set_extension:type_name -> goproto.protoc.extension.ext.MessageSetWireFormatExtension
+	56, // starting offset of method output_type sub-list
+	56, // starting offset of method input_type sub-list
+	44, // starting offset of extension type_name sub-list
+	0,  // starting offset of extension extendee sub-list
+	0,  // starting offset of field type_name sub-list
 }
 
 func init() { file_extensions_ext_ext_proto_init() }
@@ -1235,18 +1240,21 @@
 	if File_extensions_ext_ext_proto != nil {
 		return
 	}
-	extensionTypes := make([]protoreflect.ExtensionType, 44)
-	File_extensions_ext_ext_proto = protoimpl.FileBuilder{
-		RawDescriptor:        file_extensions_ext_ext_proto_rawDesc,
-		GoTypes:              file_extensions_ext_ext_proto_goTypes,
-		DependencyIndexes:    file_extensions_ext_ext_proto_depIdxs,
-		LegacyExtensions:     file_extensions_ext_ext_proto_extDescs,
-		EnumOutputTypes:      file_extensions_ext_ext_proto_enumTypes,
-		MessageOutputTypes:   file_extensions_ext_ext_proto_msgTypes,
-		ExtensionOutputTypes: extensionTypes,
-		FilesRegistry:        protoregistry.GlobalFiles,
-		TypesRegistry:        protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_extensions_ext_ext_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   8,
+			NumExtensions: 44,
+			NumServices:   0,
+		},
+		GoTypes:           file_extensions_ext_ext_proto_goTypes,
+		DependencyIndexes: file_extensions_ext_ext_proto_depIdxs,
+		MessageInfos:      file_extensions_ext_ext_proto_msgTypes,
+		LegacyExtensions:  file_extensions_ext_ext_proto_extDescs,
+	}.Build()
+	File_extensions_ext_ext_proto = out.File
+	file_extensions_ext_ext_proto_enumTypes = out.Enums
 	file_extensions_ext_ext_proto_rawDesc = nil
 	file_extensions_ext_ext_proto_goTypes = nil
 	file_extensions_ext_ext_proto_depIdxs = nil
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 e46cdba..93a95dc 100644
--- a/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/extra/extra.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -87,21 +86,32 @@
 var file_extensions_extra_extra_proto_goTypes = []interface{}{
 	(*ExtraMessage)(nil), // 0: goproto.protoc.extension.extra.ExtraMessage
 }
-var file_extensions_extra_extra_proto_depIdxs = []int32{}
+var file_extensions_extra_extra_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_extensions_extra_extra_proto_init() }
 func file_extensions_extra_extra_proto_init() {
 	if File_extensions_extra_extra_proto != nil {
 		return
 	}
-	File_extensions_extra_extra_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_extensions_extra_extra_proto_rawDesc,
-		GoTypes:            file_extensions_extra_extra_proto_goTypes,
-		DependencyIndexes:  file_extensions_extra_extra_proto_depIdxs,
-		MessageOutputTypes: file_extensions_extra_extra_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_extensions_extra_extra_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_extensions_extra_extra_proto_goTypes,
+		DependencyIndexes: file_extensions_extra_extra_proto_depIdxs,
+		MessageInfos:      file_extensions_extra_extra_proto_msgTypes,
+	}.Build()
+	File_extensions_extra_extra_proto = out.File
 	file_extensions_extra_extra_proto_rawDesc = nil
 	file_extensions_extra_extra_proto_goTypes = nil
 	file_extensions_extra_extra_proto_depIdxs = nil
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 f98c06b..c88a642 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	descriptorpb "google.golang.org/protobuf/types/descriptorpb"
@@ -46,7 +46,7 @@
 }
 
 func (Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_extensions_proto3_ext3_proto_enumTypes[0].Descriptor()
+	return file_extensions_proto3_ext3_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x Enum) Number() protoreflect.EnumNumber {
@@ -686,7 +686,7 @@
 	return file_extensions_proto3_ext3_proto_rawDescData
 }
 
-var file_extensions_proto3_ext3_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_extensions_proto3_ext3_proto_enumTypes = make([]prototype.Enum, 1)
 var file_extensions_proto3_ext3_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
 var file_extensions_proto3_ext3_proto_goTypes = []interface{}{
 	(Enum)(0),                           // 0: goproto.protoc.extension.proto3.Enum
@@ -694,44 +694,49 @@
 	(*descriptorpb.MessageOptions)(nil), // 2: google.protobuf.MessageOptions
 }
 var file_extensions_proto3_ext3_proto_depIdxs = []int32{
-	2, // goproto.protoc.extension.proto3.extension_bool:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_enum:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_int32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_sint32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_uint32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_int64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_sint64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_uint64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_sfixed32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_fixed32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_float:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_sfixed64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_fixed64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_double:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_string:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_bytes:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.extension_Message:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_bool:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_enum:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_int32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_sint32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_uint32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_int64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_sint64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_uint64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_sfixed32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_fixed32:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_float:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_sfixed64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_fixed64:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_double:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_string:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_bytes:extendee -> google.protobuf.MessageOptions
-	2, // goproto.protoc.extension.proto3.repeated_extension_Message:extendee -> google.protobuf.MessageOptions
-	0, // goproto.protoc.extension.proto3.extension_enum:type_name -> goproto.protoc.extension.proto3.Enum
-	1, // goproto.protoc.extension.proto3.extension_Message:type_name -> goproto.protoc.extension.proto3.Message
-	0, // goproto.protoc.extension.proto3.repeated_extension_enum:type_name -> goproto.protoc.extension.proto3.Enum
-	1, // goproto.protoc.extension.proto3.repeated_extension_Message:type_name -> goproto.protoc.extension.proto3.Message
+	2,  // goproto.protoc.extension.proto3.extension_bool:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_enum:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_int32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_sint32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_uint32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_int64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_sint64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_uint64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_sfixed32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_fixed32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_float:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_sfixed64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_fixed64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_double:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_string:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_bytes:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.extension_Message:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_bool:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_enum:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_int32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_sint32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_uint32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_int64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_sint64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_uint64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_sfixed32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_fixed32:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_float:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_sfixed64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_fixed64:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_double:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_string:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_bytes:extendee -> google.protobuf.MessageOptions
+	2,  // goproto.protoc.extension.proto3.repeated_extension_Message:extendee -> google.protobuf.MessageOptions
+	0,  // goproto.protoc.extension.proto3.extension_enum:type_name -> goproto.protoc.extension.proto3.Enum
+	1,  // goproto.protoc.extension.proto3.extension_Message:type_name -> goproto.protoc.extension.proto3.Message
+	0,  // goproto.protoc.extension.proto3.repeated_extension_enum:type_name -> goproto.protoc.extension.proto3.Enum
+	1,  // goproto.protoc.extension.proto3.repeated_extension_Message:type_name -> goproto.protoc.extension.proto3.Message
+	38, // starting offset of method output_type sub-list
+	38, // starting offset of method input_type sub-list
+	34, // starting offset of extension type_name sub-list
+	0,  // starting offset of extension extendee sub-list
+	0,  // starting offset of field type_name sub-list
 }
 
 func init() { file_extensions_proto3_ext3_proto_init() }
@@ -739,18 +744,21 @@
 	if File_extensions_proto3_ext3_proto != nil {
 		return
 	}
-	extensionTypes := make([]protoreflect.ExtensionType, 34)
-	File_extensions_proto3_ext3_proto = protoimpl.FileBuilder{
-		RawDescriptor:        file_extensions_proto3_ext3_proto_rawDesc,
-		GoTypes:              file_extensions_proto3_ext3_proto_goTypes,
-		DependencyIndexes:    file_extensions_proto3_ext3_proto_depIdxs,
-		LegacyExtensions:     file_extensions_proto3_ext3_proto_extDescs,
-		EnumOutputTypes:      file_extensions_proto3_ext3_proto_enumTypes,
-		MessageOutputTypes:   file_extensions_proto3_ext3_proto_msgTypes,
-		ExtensionOutputTypes: extensionTypes,
-		FilesRegistry:        protoregistry.GlobalFiles,
-		TypesRegistry:        protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_extensions_proto3_ext3_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   1,
+			NumExtensions: 34,
+			NumServices:   0,
+		},
+		GoTypes:           file_extensions_proto3_ext3_proto_goTypes,
+		DependencyIndexes: file_extensions_proto3_ext3_proto_depIdxs,
+		MessageInfos:      file_extensions_proto3_ext3_proto_msgTypes,
+		LegacyExtensions:  file_extensions_proto3_ext3_proto_extDescs,
+	}.Build()
+	File_extensions_proto3_ext3_proto = out.File
+	file_extensions_proto3_ext3_proto_enumTypes = out.Enums
 	file_extensions_proto3_ext3_proto_rawDesc = nil
 	file_extensions_proto3_ext3_proto_goTypes = nil
 	file_extensions_proto3_ext3_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index 8680fd2..9a9b3cb 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -382,21 +381,32 @@
 	(*Message)(nil),                      // 0: goproto.protoc.fieldnames.Message
 	(*Message_OneofMessageConflict)(nil), // 1: goproto.protoc.fieldnames.Message.OneofMessageConflict
 }
-var file_fieldnames_fieldnames_proto_depIdxs = []int32{}
+var file_fieldnames_fieldnames_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_fieldnames_fieldnames_proto_init() }
 func file_fieldnames_fieldnames_proto_init() {
 	if File_fieldnames_fieldnames_proto != nil {
 		return
 	}
-	File_fieldnames_fieldnames_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_fieldnames_fieldnames_proto_rawDesc,
-		GoTypes:            file_fieldnames_fieldnames_proto_goTypes,
-		DependencyIndexes:  file_fieldnames_fieldnames_proto_depIdxs,
-		MessageOutputTypes: file_fieldnames_fieldnames_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_fieldnames_fieldnames_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_fieldnames_fieldnames_proto_goTypes,
+		DependencyIndexes: file_fieldnames_fieldnames_proto_depIdxs,
+		MessageInfos:      file_fieldnames_fieldnames_proto_msgTypes,
+	}.Build()
+	File_fieldnames_fieldnames_proto = out.File
 	file_fieldnames_fieldnames_proto_rawDesc = nil
 	file_fieldnames_fieldnames_proto_goTypes = nil
 	file_fieldnames_fieldnames_proto_depIdxs = nil
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 d142745..9ff5681 100644
--- a/cmd/protoc-gen-go/testdata/import_public/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/a.pb.go
@@ -6,7 +6,6 @@
 import (
 	sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -160,6 +159,11 @@
 	1, // goproto.protoc.import_public.Public.m:type_name -> goproto.protoc.import_public.sub.M
 	2, // goproto.protoc.import_public.Public.e:type_name -> goproto.protoc.import_public.sub.E
 	3, // goproto.protoc.import_public.Public.local:type_name -> goproto.protoc.import_public.Local
+	3, // starting offset of method output_type sub-list
+	3, // starting offset of method input_type sub-list
+	3, // starting offset of extension type_name sub-list
+	3, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_import_public_a_proto_init() }
@@ -168,14 +172,19 @@
 		return
 	}
 	file_import_public_b_proto_init()
-	File_import_public_a_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_import_public_a_proto_rawDesc,
-		GoTypes:            file_import_public_a_proto_goTypes,
-		DependencyIndexes:  file_import_public_a_proto_depIdxs,
-		MessageOutputTypes: file_import_public_a_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_a_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_a_proto_goTypes,
+		DependencyIndexes: file_import_public_a_proto_depIdxs,
+		MessageInfos:      file_import_public_a_proto_msgTypes,
+	}.Build()
+	File_import_public_a_proto = out.File
 	file_import_public_a_proto_rawDesc = nil
 	file_import_public_a_proto_goTypes = nil
 	file_import_public_a_proto_depIdxs = nil
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 8fc7556..da6a3a6 100644
--- a/cmd/protoc-gen-go/testdata/import_public/b.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/b.pb.go
@@ -6,7 +6,6 @@
 import (
 	sub "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -107,6 +106,11 @@
 var file_import_public_b_proto_depIdxs = []int32{
 	1, // goproto.protoc.import_public.Local.m:type_name -> goproto.protoc.import_public.sub.M
 	2, // goproto.protoc.import_public.Local.e:type_name -> goproto.protoc.import_public.sub.E
+	2, // starting offset of method output_type sub-list
+	2, // starting offset of method input_type sub-list
+	2, // starting offset of extension type_name sub-list
+	2, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_import_public_b_proto_init() }
@@ -114,14 +118,19 @@
 	if File_import_public_b_proto != nil {
 		return
 	}
-	File_import_public_b_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_import_public_b_proto_rawDesc,
-		GoTypes:            file_import_public_b_proto_goTypes,
-		DependencyIndexes:  file_import_public_b_proto_depIdxs,
-		MessageOutputTypes: file_import_public_b_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_b_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_b_proto_goTypes,
+		DependencyIndexes: file_import_public_b_proto_depIdxs,
+		MessageInfos:      file_import_public_b_proto_msgTypes,
+	}.Build()
+	File_import_public_b_proto = out.File
 	file_import_public_b_proto_rawDesc = nil
 	file_import_public_b_proto_goTypes = nil
 	file_import_public_b_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/import_public/c.pb.go b/cmd/protoc-gen-go/testdata/import_public/c.pb.go
index 07d1578..955f91b 100644
--- a/cmd/protoc-gen-go/testdata/import_public/c.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/c.pb.go
@@ -6,7 +6,6 @@
 import (
 	sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -112,6 +111,11 @@
 var file_import_public_c_proto_depIdxs = []int32{
 	1, // goproto.protoc.import_public.UsingPublicImport.local:type_name -> goproto.protoc.import_public.Local
 	2, // goproto.protoc.import_public.UsingPublicImport.sub2:type_name -> goproto.protoc.import_public.sub2.Sub2Message
+	2, // starting offset of method output_type sub-list
+	2, // starting offset of method input_type sub-list
+	2, // starting offset of extension type_name sub-list
+	2, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_import_public_c_proto_init() }
@@ -120,14 +124,19 @@
 		return
 	}
 	file_import_public_a_proto_init()
-	File_import_public_c_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_import_public_c_proto_rawDesc,
-		GoTypes:            file_import_public_c_proto_goTypes,
-		DependencyIndexes:  file_import_public_c_proto_depIdxs,
-		MessageOutputTypes: file_import_public_c_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_c_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_c_proto_goTypes,
+		DependencyIndexes: file_import_public_c_proto_depIdxs,
+		MessageInfos:      file_import_public_c_proto_msgTypes,
+	}.Build()
+	File_import_public_c_proto = out.File
 	file_import_public_c_proto_rawDesc = nil
 	file_import_public_c_proto_goTypes = nil
 	file_import_public_c_proto_depIdxs = nil
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 68f0084..fc5a845 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
@@ -6,7 +6,7 @@
 import (
 	sub2 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/import_public/sub2"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	math "math"
@@ -51,7 +51,7 @@
 }
 
 func (E) Descriptor() protoreflect.EnumDescriptor {
-	return file_import_public_sub_a_proto_enumTypes[0].Descriptor()
+	return file_import_public_sub_a_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x E) Number() protoreflect.EnumNumber {
@@ -100,7 +100,7 @@
 }
 
 func (M_Subenum) Descriptor() protoreflect.EnumDescriptor {
-	return file_import_public_sub_a_proto_enumTypes[1].Descriptor()
+	return file_import_public_sub_a_proto_enumTypes[1].EnumDescriptor
 }
 
 func (x M_Subenum) Number() protoreflect.EnumNumber {
@@ -149,7 +149,7 @@
 }
 
 func (M_Submessage_Submessage_Subenum) Descriptor() protoreflect.EnumDescriptor {
-	return file_import_public_sub_a_proto_enumTypes[2].Descriptor()
+	return file_import_public_sub_a_proto_enumTypes[2].EnumDescriptor
 }
 
 func (x M_Submessage_Submessage_Subenum) Number() protoreflect.EnumNumber {
@@ -452,7 +452,7 @@
 	return file_import_public_sub_a_proto_rawDescData
 }
 
-var file_import_public_sub_a_proto_enumTypes = make([]protoreflect.EnumType, 3)
+var file_import_public_sub_a_proto_enumTypes = make([]prototype.Enum, 3)
 var file_import_public_sub_a_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
 var file_import_public_sub_a_proto_goTypes = []interface{}{
 	(E)(0),                               // 0: goproto.protoc.import_public.sub.E
@@ -463,8 +463,13 @@
 	(*M2)(nil),                           // 5: goproto.protoc.import_public.sub.M2
 }
 var file_import_public_sub_a_proto_depIdxs = []int32{
-	3, // goproto.protoc.import_public.sub.extension_field:extendee -> goproto.protoc.import_public.sub.M
 	5, // goproto.protoc.import_public.sub.M.m2:type_name -> goproto.protoc.import_public.sub.M2
+	3, // goproto.protoc.import_public.sub.extension_field:extendee -> goproto.protoc.import_public.sub.M
+	2, // starting offset of method output_type sub-list
+	2, // starting offset of method input_type sub-list
+	2, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_import_public_sub_a_proto_init() }
@@ -473,18 +478,21 @@
 		return
 	}
 	file_import_public_sub_b_proto_init()
-	extensionTypes := make([]protoreflect.ExtensionType, 1)
-	File_import_public_sub_a_proto = protoimpl.FileBuilder{
-		RawDescriptor:        file_import_public_sub_a_proto_rawDesc,
-		GoTypes:              file_import_public_sub_a_proto_goTypes,
-		DependencyIndexes:    file_import_public_sub_a_proto_depIdxs,
-		LegacyExtensions:     file_import_public_sub_a_proto_extDescs,
-		EnumOutputTypes:      file_import_public_sub_a_proto_enumTypes,
-		MessageOutputTypes:   file_import_public_sub_a_proto_msgTypes,
-		ExtensionOutputTypes: extensionTypes,
-		FilesRegistry:        protoregistry.GlobalFiles,
-		TypesRegistry:        protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_sub_a_proto_rawDesc,
+			NumEnums:      3,
+			NumMessages:   2,
+			NumExtensions: 1,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_sub_a_proto_goTypes,
+		DependencyIndexes: file_import_public_sub_a_proto_depIdxs,
+		MessageInfos:      file_import_public_sub_a_proto_msgTypes,
+		LegacyExtensions:  file_import_public_sub_a_proto_extDescs,
+	}.Build()
+	File_import_public_sub_a_proto = out.File
+	file_import_public_sub_a_proto_enumTypes = out.Enums
 	file_import_public_sub_a_proto_rawDesc = nil
 	file_import_public_sub_a_proto_goTypes = nil
 	file_import_public_sub_a_proto_depIdxs = nil
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 114c142..dfa99ab 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -77,21 +76,32 @@
 var file_import_public_sub_b_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: goproto.protoc.import_public.sub.M2
 }
-var file_import_public_sub_b_proto_depIdxs = []int32{}
+var file_import_public_sub_b_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_import_public_sub_b_proto_init() }
 func file_import_public_sub_b_proto_init() {
 	if File_import_public_sub_b_proto != nil {
 		return
 	}
-	File_import_public_sub_b_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_import_public_sub_b_proto_rawDesc,
-		GoTypes:            file_import_public_sub_b_proto_goTypes,
-		DependencyIndexes:  file_import_public_sub_b_proto_depIdxs,
-		MessageOutputTypes: file_import_public_sub_b_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_sub_b_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_sub_b_proto_goTypes,
+		DependencyIndexes: file_import_public_sub_b_proto_depIdxs,
+		MessageInfos:      file_import_public_sub_b_proto_msgTypes,
+	}.Build()
+	File_import_public_sub_b_proto = out.File
 	file_import_public_sub_b_proto_rawDesc = nil
 	file_import_public_sub_b_proto_goTypes = nil
 	file_import_public_sub_b_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
index 4b84080..cde2a6f 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub2/a.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -78,21 +77,32 @@
 var file_import_public_sub2_a_proto_goTypes = []interface{}{
 	(*Sub2Message)(nil), // 0: goproto.protoc.import_public.sub2.Sub2Message
 }
-var file_import_public_sub2_a_proto_depIdxs = []int32{}
+var file_import_public_sub2_a_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_import_public_sub2_a_proto_init() }
 func file_import_public_sub2_a_proto_init() {
 	if File_import_public_sub2_a_proto != nil {
 		return
 	}
-	File_import_public_sub2_a_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_import_public_sub2_a_proto_rawDesc,
-		GoTypes:            file_import_public_sub2_a_proto_goTypes,
-		DependencyIndexes:  file_import_public_sub2_a_proto_depIdxs,
-		MessageOutputTypes: file_import_public_sub2_a_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_import_public_sub2_a_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_import_public_sub2_a_proto_goTypes,
+		DependencyIndexes: file_import_public_sub2_a_proto_depIdxs,
+		MessageInfos:      file_import_public_sub2_a_proto_msgTypes,
+	}.Build()
+	File_import_public_sub2_a_proto = out.File
 	file_import_public_sub2_a_proto_rawDesc = nil
 	file_import_public_sub2_a_proto_goTypes = nil
 	file_import_public_sub2_a_proto_depIdxs = nil
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 db047a2..8cdb704 100644
--- a/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/fmt/m.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -75,21 +74,32 @@
 var file_imports_fmt_m_proto_goTypes = []interface{}{
 	(*M)(nil), // 0: fmt.M
 }
-var file_imports_fmt_m_proto_depIdxs = []int32{}
+var file_imports_fmt_m_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_fmt_m_proto_init() }
 func file_imports_fmt_m_proto_init() {
 	if File_imports_fmt_m_proto != nil {
 		return
 	}
-	File_imports_fmt_m_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_fmt_m_proto_rawDesc,
-		GoTypes:            file_imports_fmt_m_proto_goTypes,
-		DependencyIndexes:  file_imports_fmt_m_proto_depIdxs,
-		MessageOutputTypes: file_imports_fmt_m_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_fmt_m_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_fmt_m_proto_goTypes,
+		DependencyIndexes: file_imports_fmt_m_proto_depIdxs,
+		MessageInfos:      file_imports_fmt_m_proto_msgTypes,
+	}.Build()
+	File_imports_fmt_m_proto = out.File
 	file_imports_fmt_m_proto_rawDesc = nil
 	file_imports_fmt_m_proto_goTypes = nil
 	file_imports_fmt_m_proto_depIdxs = nil
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 8530e07..1106dc6 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
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -45,7 +45,7 @@
 }
 
 func (E1) Descriptor() protoreflect.EnumDescriptor {
-	return file_imports_test_a_1_m1_proto_enumTypes[0].Descriptor()
+	return file_imports_test_a_1_m1_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x E1) Number() protoreflect.EnumNumber {
@@ -152,7 +152,7 @@
 	return file_imports_test_a_1_m1_proto_rawDescData
 }
 
-var file_imports_test_a_1_m1_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_imports_test_a_1_m1_proto_enumTypes = make([]prototype.Enum, 1)
 var file_imports_test_a_1_m1_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
 var file_imports_test_a_1_m1_proto_goTypes = []interface{}{
 	(E1)(0),      // 0: test.a.E1
@@ -161,6 +161,11 @@
 }
 var file_imports_test_a_1_m1_proto_depIdxs = []int32{
 	1, // test.a.M1_1.m1:type_name -> test.a.M1
+	1, // starting offset of method output_type sub-list
+	1, // starting offset of method input_type sub-list
+	1, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_imports_test_a_1_m1_proto_init() }
@@ -168,15 +173,20 @@
 	if File_imports_test_a_1_m1_proto != nil {
 		return
 	}
-	File_imports_test_a_1_m1_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_a_1_m1_proto_rawDesc,
-		GoTypes:            file_imports_test_a_1_m1_proto_goTypes,
-		DependencyIndexes:  file_imports_test_a_1_m1_proto_depIdxs,
-		EnumOutputTypes:    file_imports_test_a_1_m1_proto_enumTypes,
-		MessageOutputTypes: file_imports_test_a_1_m1_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_a_1_m1_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_a_1_m1_proto_goTypes,
+		DependencyIndexes: file_imports_test_a_1_m1_proto_depIdxs,
+		MessageInfos:      file_imports_test_a_1_m1_proto_msgTypes,
+	}.Build()
+	File_imports_test_a_1_m1_proto = out.File
+	file_imports_test_a_1_m1_proto_enumTypes = out.Enums
 	file_imports_test_a_1_m1_proto_rawDesc = nil
 	file_imports_test_a_1_m1_proto_goTypes = nil
 	file_imports_test_a_1_m1_proto_depIdxs = nil
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 911f7b2..1884c23 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -76,21 +75,32 @@
 var file_imports_test_a_1_m2_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: test.a.M2
 }
-var file_imports_test_a_1_m2_proto_depIdxs = []int32{}
+var file_imports_test_a_1_m2_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_test_a_1_m2_proto_init() }
 func file_imports_test_a_1_m2_proto_init() {
 	if File_imports_test_a_1_m2_proto != nil {
 		return
 	}
-	File_imports_test_a_1_m2_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_a_1_m2_proto_rawDesc,
-		GoTypes:            file_imports_test_a_1_m2_proto_goTypes,
-		DependencyIndexes:  file_imports_test_a_1_m2_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_a_1_m2_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_a_1_m2_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_a_1_m2_proto_goTypes,
+		DependencyIndexes: file_imports_test_a_1_m2_proto_depIdxs,
+		MessageInfos:      file_imports_test_a_1_m2_proto_msgTypes,
+	}.Build()
+	File_imports_test_a_1_m2_proto = out.File
 	file_imports_test_a_1_m2_proto_rawDesc = nil
 	file_imports_test_a_1_m2_proto_goTypes = nil
 	file_imports_test_a_1_m2_proto_depIdxs = nil
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 fa28027..319f61f 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -76,21 +75,32 @@
 var file_imports_test_a_2_m3_proto_goTypes = []interface{}{
 	(*M3)(nil), // 0: test.a.M3
 }
-var file_imports_test_a_2_m3_proto_depIdxs = []int32{}
+var file_imports_test_a_2_m3_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_test_a_2_m3_proto_init() }
 func file_imports_test_a_2_m3_proto_init() {
 	if File_imports_test_a_2_m3_proto != nil {
 		return
 	}
-	File_imports_test_a_2_m3_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_a_2_m3_proto_rawDesc,
-		GoTypes:            file_imports_test_a_2_m3_proto_goTypes,
-		DependencyIndexes:  file_imports_test_a_2_m3_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_a_2_m3_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_a_2_m3_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_a_2_m3_proto_goTypes,
+		DependencyIndexes: file_imports_test_a_2_m3_proto_depIdxs,
+		MessageInfos:      file_imports_test_a_2_m3_proto_msgTypes,
+	}.Build()
+	File_imports_test_a_2_m3_proto = out.File
 	file_imports_test_a_2_m3_proto_rawDesc = nil
 	file_imports_test_a_2_m3_proto_goTypes = nil
 	file_imports_test_a_2_m3_proto_depIdxs = nil
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 0d86e4e..47695eb 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -76,21 +75,32 @@
 var file_imports_test_a_2_m4_proto_goTypes = []interface{}{
 	(*M4)(nil), // 0: test.a.M4
 }
-var file_imports_test_a_2_m4_proto_depIdxs = []int32{}
+var file_imports_test_a_2_m4_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_test_a_2_m4_proto_init() }
 func file_imports_test_a_2_m4_proto_init() {
 	if File_imports_test_a_2_m4_proto != nil {
 		return
 	}
-	File_imports_test_a_2_m4_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_a_2_m4_proto_rawDesc,
-		GoTypes:            file_imports_test_a_2_m4_proto_goTypes,
-		DependencyIndexes:  file_imports_test_a_2_m4_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_a_2_m4_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_a_2_m4_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_a_2_m4_proto_goTypes,
+		DependencyIndexes: file_imports_test_a_2_m4_proto_depIdxs,
+		MessageInfos:      file_imports_test_a_2_m4_proto_msgTypes,
+	}.Build()
+	File_imports_test_a_2_m4_proto = out.File
 	file_imports_test_a_2_m4_proto_rawDesc = nil
 	file_imports_test_a_2_m4_proto_goTypes = nil
 	file_imports_test_a_2_m4_proto_depIdxs = nil
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 0dc09b0..acda349 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -77,21 +76,32 @@
 var file_imports_test_b_1_m1_proto_goTypes = []interface{}{
 	(*M1)(nil), // 0: test.b.part1.M1
 }
-var file_imports_test_b_1_m1_proto_depIdxs = []int32{}
+var file_imports_test_b_1_m1_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_test_b_1_m1_proto_init() }
 func file_imports_test_b_1_m1_proto_init() {
 	if File_imports_test_b_1_m1_proto != nil {
 		return
 	}
-	File_imports_test_b_1_m1_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_b_1_m1_proto_rawDesc,
-		GoTypes:            file_imports_test_b_1_m1_proto_goTypes,
-		DependencyIndexes:  file_imports_test_b_1_m1_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_b_1_m1_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_b_1_m1_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_b_1_m1_proto_goTypes,
+		DependencyIndexes: file_imports_test_b_1_m1_proto_depIdxs,
+		MessageInfos:      file_imports_test_b_1_m1_proto_msgTypes,
+	}.Build()
+	File_imports_test_b_1_m1_proto = out.File
 	file_imports_test_b_1_m1_proto_rawDesc = nil
 	file_imports_test_b_1_m1_proto_goTypes = nil
 	file_imports_test_b_1_m1_proto_depIdxs = nil
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 484a323..16e918f 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
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -77,21 +76,32 @@
 var file_imports_test_b_1_m2_proto_goTypes = []interface{}{
 	(*M2)(nil), // 0: test.b.part2.M2
 }
-var file_imports_test_b_1_m2_proto_depIdxs = []int32{}
+var file_imports_test_b_1_m2_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_imports_test_b_1_m2_proto_init() }
 func file_imports_test_b_1_m2_proto_init() {
 	if File_imports_test_b_1_m2_proto != nil {
 		return
 	}
-	File_imports_test_b_1_m2_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_b_1_m2_proto_rawDesc,
-		GoTypes:            file_imports_test_b_1_m2_proto_goTypes,
-		DependencyIndexes:  file_imports_test_b_1_m2_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_b_1_m2_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_b_1_m2_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_b_1_m2_proto_goTypes,
+		DependencyIndexes: file_imports_test_b_1_m2_proto_depIdxs,
+		MessageInfos:      file_imports_test_b_1_m2_proto_msgTypes,
+	}.Build()
+	File_imports_test_b_1_m2_proto = out.File
 	file_imports_test_b_1_m2_proto_rawDesc = nil
 	file_imports_test_b_1_m2_proto_goTypes = nil
 	file_imports_test_b_1_m2_proto_depIdxs = nil
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 b893f08..9d28776 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
@@ -6,7 +6,6 @@
 import (
 	test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -91,6 +90,11 @@
 }
 var file_imports_test_import_a1m1_proto_depIdxs = []int32{
 	1, // test.A1M1.f:type_name -> test.a.M1
+	1, // starting offset of method output_type sub-list
+	1, // starting offset of method input_type sub-list
+	1, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_imports_test_import_a1m1_proto_init() }
@@ -98,14 +102,19 @@
 	if File_imports_test_import_a1m1_proto != nil {
 		return
 	}
-	File_imports_test_import_a1m1_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_import_a1m1_proto_rawDesc,
-		GoTypes:            file_imports_test_import_a1m1_proto_goTypes,
-		DependencyIndexes:  file_imports_test_import_a1m1_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_import_a1m1_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_import_a1m1_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_import_a1m1_proto_goTypes,
+		DependencyIndexes: file_imports_test_import_a1m1_proto_depIdxs,
+		MessageInfos:      file_imports_test_import_a1m1_proto_msgTypes,
+	}.Build()
+	File_imports_test_import_a1m1_proto = out.File
 	file_imports_test_import_a1m1_proto_rawDesc = nil
 	file_imports_test_import_a1m1_proto_goTypes = nil
 	file_imports_test_import_a1m1_proto_depIdxs = nil
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 06a25da..55d689a 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
@@ -6,7 +6,6 @@
 import (
 	test_a_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_1"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -91,6 +90,11 @@
 }
 var file_imports_test_import_a1m2_proto_depIdxs = []int32{
 	1, // test.A1M2.f:type_name -> test.a.M2
+	1, // starting offset of method output_type sub-list
+	1, // starting offset of method input_type sub-list
+	1, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_imports_test_import_a1m2_proto_init() }
@@ -98,14 +102,19 @@
 	if File_imports_test_import_a1m2_proto != nil {
 		return
 	}
-	File_imports_test_import_a1m2_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_import_a1m2_proto_rawDesc,
-		GoTypes:            file_imports_test_import_a1m2_proto_goTypes,
-		DependencyIndexes:  file_imports_test_import_a1m2_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_import_a1m2_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_import_a1m2_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_import_a1m2_proto_goTypes,
+		DependencyIndexes: file_imports_test_import_a1m2_proto_depIdxs,
+		MessageInfos:      file_imports_test_import_a1m2_proto_msgTypes,
+	}.Build()
+	File_imports_test_import_a1m2_proto = out.File
 	file_imports_test_import_a1m2_proto_rawDesc = nil
 	file_imports_test_import_a1m2_proto_goTypes = nil
 	file_imports_test_import_a1m2_proto_depIdxs = nil
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 2f50784..cd82745 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
@@ -9,7 +9,6 @@
 	_ "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_a_2"
 	test_b_1 "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/imports/test_b_1"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -152,6 +151,11 @@
 	3, // test.All.bm1:type_name -> test.b.part1.M1
 	4, // test.All.bm2:type_name -> test.b.part2.M2
 	5, // test.All.fmt:type_name -> fmt.M
+	5, // starting offset of method output_type sub-list
+	5, // starting offset of method input_type sub-list
+	5, // starting offset of extension type_name sub-list
+	5, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_imports_test_import_all_proto_init() }
@@ -159,14 +163,19 @@
 	if File_imports_test_import_all_proto != nil {
 		return
 	}
-	File_imports_test_import_all_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_imports_test_import_all_proto_rawDesc,
-		GoTypes:            file_imports_test_import_all_proto_goTypes,
-		DependencyIndexes:  file_imports_test_import_all_proto_depIdxs,
-		MessageOutputTypes: file_imports_test_import_all_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_imports_test_import_all_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_imports_test_import_all_proto_goTypes,
+		DependencyIndexes: file_imports_test_import_all_proto_depIdxs,
+		MessageInfos:      file_imports_test_import_all_proto_msgTypes,
+	}.Build()
+	File_imports_test_import_all_proto = out.File
 	file_imports_test_import_all_proto_rawDesc = nil
 	file_imports_test_import_all_proto_goTypes = nil
 	file_imports_test_import_all_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
index 2d997fb..45db54d 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -108,21 +107,32 @@
 var file_issue780_oneof_conflict_test_proto_goTypes = []interface{}{
 	(*Foo)(nil), // 0: oneoftest.Foo
 }
-var file_issue780_oneof_conflict_test_proto_depIdxs = []int32{}
+var file_issue780_oneof_conflict_test_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_issue780_oneof_conflict_test_proto_init() }
 func file_issue780_oneof_conflict_test_proto_init() {
 	if File_issue780_oneof_conflict_test_proto != nil {
 		return
 	}
-	File_issue780_oneof_conflict_test_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_issue780_oneof_conflict_test_proto_rawDesc,
-		GoTypes:            file_issue780_oneof_conflict_test_proto_goTypes,
-		DependencyIndexes:  file_issue780_oneof_conflict_test_proto_depIdxs,
-		MessageOutputTypes: file_issue780_oneof_conflict_test_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_issue780_oneof_conflict_test_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_issue780_oneof_conflict_test_proto_goTypes,
+		DependencyIndexes: file_issue780_oneof_conflict_test_proto_depIdxs,
+		MessageInfos:      file_issue780_oneof_conflict_test_proto_msgTypes,
+	}.Build()
+	File_issue780_oneof_conflict_test_proto = out.File
 	file_issue780_oneof_conflict_test_proto_rawDesc = nil
 	file_issue780_oneof_conflict_test_proto_goTypes = nil
 	file_issue780_oneof_conflict_test_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index a9e3cf5..15c743f 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -45,7 +45,7 @@
 }
 
 func (Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_nopackage_nopackage_proto_enumTypes[0].Descriptor()
+	return file_nopackage_nopackage_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x Enum) Number() protoreflect.EnumNumber {
@@ -140,7 +140,7 @@
 	return file_nopackage_nopackage_proto_rawDescData
 }
 
-var file_nopackage_nopackage_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_nopackage_nopackage_proto_enumTypes = make([]prototype.Enum, 1)
 var file_nopackage_nopackage_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
 var file_nopackage_nopackage_proto_goTypes = []interface{}{
 	(Enum)(0),       // 0: Enum
@@ -148,6 +148,11 @@
 }
 var file_nopackage_nopackage_proto_depIdxs = []int32{
 	0, // Message.enum_field:type_name -> Enum
+	1, // starting offset of method output_type sub-list
+	1, // starting offset of method input_type sub-list
+	1, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_nopackage_nopackage_proto_init() }
@@ -155,15 +160,20 @@
 	if File_nopackage_nopackage_proto != nil {
 		return
 	}
-	File_nopackage_nopackage_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_nopackage_nopackage_proto_rawDesc,
-		GoTypes:            file_nopackage_nopackage_proto_goTypes,
-		DependencyIndexes:  file_nopackage_nopackage_proto_depIdxs,
-		EnumOutputTypes:    file_nopackage_nopackage_proto_enumTypes,
-		MessageOutputTypes: file_nopackage_nopackage_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_nopackage_nopackage_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_nopackage_nopackage_proto_goTypes,
+		DependencyIndexes: file_nopackage_nopackage_proto_depIdxs,
+		MessageInfos:      file_nopackage_nopackage_proto_msgTypes,
+	}.Build()
+	File_nopackage_nopackage_proto = out.File
+	file_nopackage_nopackage_proto_enumTypes = out.Enums
 	file_nopackage_nopackage_proto_rawDesc = nil
 	file_nopackage_nopackage_proto_goTypes = nil
 	file_nopackage_nopackage_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index 8f9c18b..b741f56 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -51,7 +51,7 @@
 }
 
 func (EnumType1) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[0].Descriptor()
+	return file_proto2_enum_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x EnumType1) Number() protoreflect.EnumNumber {
@@ -103,7 +103,7 @@
 }
 
 func (EnumType2) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[1].Descriptor()
+	return file_proto2_enum_proto_enumTypes[1].EnumDescriptor
 }
 
 func (x EnumType2) Number() protoreflect.EnumNumber {
@@ -154,7 +154,7 @@
 }
 
 func (EnumContainerMessage1_NestedEnumType1A) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[2].Descriptor()
+	return file_proto2_enum_proto_enumTypes[2].EnumDescriptor
 }
 
 func (x EnumContainerMessage1_NestedEnumType1A) Number() protoreflect.EnumNumber {
@@ -203,7 +203,7 @@
 }
 
 func (EnumContainerMessage1_NestedEnumType1B) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[3].Descriptor()
+	return file_proto2_enum_proto_enumTypes[3].EnumDescriptor
 }
 
 func (x EnumContainerMessage1_NestedEnumType1B) Number() protoreflect.EnumNumber {
@@ -254,7 +254,7 @@
 }
 
 func (EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[4].Descriptor()
+	return file_proto2_enum_proto_enumTypes[4].EnumDescriptor
 }
 
 func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Number() protoreflect.EnumNumber {
@@ -303,7 +303,7 @@
 }
 
 func (EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_enum_proto_enumTypes[5].Descriptor()
+	return file_proto2_enum_proto_enumTypes[5].EnumDescriptor
 }
 
 func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Number() protoreflect.EnumNumber {
@@ -458,7 +458,7 @@
 	return file_proto2_enum_proto_rawDescData
 }
 
-var file_proto2_enum_proto_enumTypes = make([]protoreflect.EnumType, 6)
+var file_proto2_enum_proto_enumTypes = make([]prototype.Enum, 6)
 var file_proto2_enum_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
 var file_proto2_enum_proto_goTypes = []interface{}{
 	(EnumType1)(0), // 0: goproto.protoc.proto2.EnumType1
@@ -473,6 +473,11 @@
 var file_proto2_enum_proto_depIdxs = []int32{
 	1, // goproto.protoc.proto2.EnumContainerMessage1.default_duplicate1:type_name -> goproto.protoc.proto2.EnumType2
 	1, // goproto.protoc.proto2.EnumContainerMessage1.default_duplicate2:type_name -> goproto.protoc.proto2.EnumType2
+	2, // starting offset of method output_type sub-list
+	2, // starting offset of method input_type sub-list
+	2, // starting offset of extension type_name sub-list
+	2, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_proto2_enum_proto_init() }
@@ -480,15 +485,20 @@
 	if File_proto2_enum_proto != nil {
 		return
 	}
-	File_proto2_enum_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_proto2_enum_proto_rawDesc,
-		GoTypes:            file_proto2_enum_proto_goTypes,
-		DependencyIndexes:  file_proto2_enum_proto_depIdxs,
-		EnumOutputTypes:    file_proto2_enum_proto_enumTypes,
-		MessageOutputTypes: file_proto2_enum_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto2_enum_proto_rawDesc,
+			NumEnums:      6,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_proto2_enum_proto_goTypes,
+		DependencyIndexes: file_proto2_enum_proto_depIdxs,
+		MessageInfos:      file_proto2_enum_proto_msgTypes,
+	}.Build()
+	File_proto2_enum_proto = out.File
+	file_proto2_enum_proto_enumTypes = out.Enums
 	file_proto2_enum_proto_rawDesc = nil
 	file_proto2_enum_proto_goTypes = nil
 	file_proto2_enum_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index afc649d..58970fc 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	math "math"
@@ -49,7 +49,7 @@
 }
 
 func (FieldTestMessage_Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto2_fields_proto_enumTypes[0].Descriptor()
+	return file_proto2_fields_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
@@ -1687,7 +1687,7 @@
 	return file_proto2_fields_proto_rawDescData
 }
 
-var file_proto2_fields_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_proto2_fields_proto_enumTypes = make([]prototype.Enum, 1)
 var file_proto2_fields_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
 var file_proto2_fields_proto_goTypes = []interface{}{
 	(FieldTestMessage_Enum)(0),             // 0: goproto.protoc.proto2.FieldTestMessage.Enum
@@ -1702,24 +1702,29 @@
 	(*FieldTestMessage_Message)(nil),       // 9: goproto.protoc.proto2.FieldTestMessage.Message
 }
 var file_proto2_fields_proto_depIdxs = []int32{
-	0, // goproto.protoc.proto2.FieldTestMessage.optional_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
-	9, // goproto.protoc.proto2.FieldTestMessage.optional_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
-	2, // goproto.protoc.proto2.FieldTestMessage.optionalgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.OptionalGroup
-	0, // goproto.protoc.proto2.FieldTestMessage.required_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
-	9, // goproto.protoc.proto2.FieldTestMessage.required_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
-	3, // goproto.protoc.proto2.FieldTestMessage.requiredgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.RequiredGroup
-	0, // goproto.protoc.proto2.FieldTestMessage.repeated_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
-	9, // goproto.protoc.proto2.FieldTestMessage.repeated_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
-	4, // goproto.protoc.proto2.FieldTestMessage.repeatedgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.RepeatedGroup
-	0, // goproto.protoc.proto2.FieldTestMessage.default_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
-	5, // goproto.protoc.proto2.FieldTestMessage.map_int32_int64:type_name -> goproto.protoc.proto2.FieldTestMessage.MapInt32Int64Entry
-	6, // goproto.protoc.proto2.FieldTestMessage.map_string_message:type_name -> goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry
-	7, // goproto.protoc.proto2.FieldTestMessage.map_fixed64_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry
-	0, // goproto.protoc.proto2.FieldTestMessage.oneof_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
-	9, // goproto.protoc.proto2.FieldTestMessage.oneof_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
-	8, // goproto.protoc.proto2.FieldTestMessage.oneofgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.OneofGroup
-	9, // goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry.value:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
-	0, // goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry.value:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	0,  // goproto.protoc.proto2.FieldTestMessage.optional_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	9,  // goproto.protoc.proto2.FieldTestMessage.optional_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
+	2,  // goproto.protoc.proto2.FieldTestMessage.optionalgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.OptionalGroup
+	0,  // goproto.protoc.proto2.FieldTestMessage.required_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	9,  // goproto.protoc.proto2.FieldTestMessage.required_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
+	3,  // goproto.protoc.proto2.FieldTestMessage.requiredgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.RequiredGroup
+	0,  // goproto.protoc.proto2.FieldTestMessage.repeated_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	9,  // goproto.protoc.proto2.FieldTestMessage.repeated_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
+	4,  // goproto.protoc.proto2.FieldTestMessage.repeatedgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.RepeatedGroup
+	0,  // goproto.protoc.proto2.FieldTestMessage.default_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	5,  // goproto.protoc.proto2.FieldTestMessage.map_int32_int64:type_name -> goproto.protoc.proto2.FieldTestMessage.MapInt32Int64Entry
+	6,  // goproto.protoc.proto2.FieldTestMessage.map_string_message:type_name -> goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry
+	7,  // goproto.protoc.proto2.FieldTestMessage.map_fixed64_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry
+	0,  // goproto.protoc.proto2.FieldTestMessage.oneof_enum:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	9,  // goproto.protoc.proto2.FieldTestMessage.oneof_Message:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
+	8,  // goproto.protoc.proto2.FieldTestMessage.oneofgroup:type_name -> goproto.protoc.proto2.FieldTestMessage.OneofGroup
+	9,  // goproto.protoc.proto2.FieldTestMessage.MapStringMessageEntry.value:type_name -> goproto.protoc.proto2.FieldTestMessage.Message
+	0,  // goproto.protoc.proto2.FieldTestMessage.MapFixed64EnumEntry.value:type_name -> goproto.protoc.proto2.FieldTestMessage.Enum
+	18, // starting offset of method output_type sub-list
+	18, // starting offset of method input_type sub-list
+	18, // starting offset of extension type_name sub-list
+	18, // starting offset of extension extendee sub-list
+	0,  // starting offset of field type_name sub-list
 }
 
 func init() { file_proto2_fields_proto_init() }
@@ -1727,15 +1732,20 @@
 	if File_proto2_fields_proto != nil {
 		return
 	}
-	File_proto2_fields_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_proto2_fields_proto_rawDesc,
-		GoTypes:            file_proto2_fields_proto_goTypes,
-		DependencyIndexes:  file_proto2_fields_proto_depIdxs,
-		EnumOutputTypes:    file_proto2_fields_proto_enumTypes,
-		MessageOutputTypes: file_proto2_fields_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto2_fields_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   9,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_proto2_fields_proto_goTypes,
+		DependencyIndexes: file_proto2_fields_proto_depIdxs,
+		MessageInfos:      file_proto2_fields_proto_msgTypes,
+	}.Build()
+	File_proto2_fields_proto = out.File
+	file_proto2_fields_proto_enumTypes = out.Enums
 	file_proto2_fields_proto_rawDesc = nil
 	file_proto2_fields_proto_goTypes = nil
 	file_proto2_fields_proto_depIdxs = nil
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 1533c5d..16da78e 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -177,6 +176,11 @@
 	1, // goproto.protoc.proto2.Layer1.l2:type_name -> goproto.protoc.proto2.Layer1.Layer2
 	2, // goproto.protoc.proto2.Layer1.l3:type_name -> goproto.protoc.proto2.Layer1.Layer2.Layer3
 	2, // goproto.protoc.proto2.Layer1.Layer2.l3:type_name -> goproto.protoc.proto2.Layer1.Layer2.Layer3
+	3, // starting offset of method output_type sub-list
+	3, // starting offset of method input_type sub-list
+	3, // starting offset of extension type_name sub-list
+	3, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_proto2_nested_messages_proto_init() }
@@ -184,14 +188,19 @@
 	if File_proto2_nested_messages_proto != nil {
 		return
 	}
-	File_proto2_nested_messages_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_proto2_nested_messages_proto_rawDesc,
-		GoTypes:            file_proto2_nested_messages_proto_goTypes,
-		DependencyIndexes:  file_proto2_nested_messages_proto_depIdxs,
-		MessageOutputTypes: file_proto2_nested_messages_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto2_nested_messages_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   3,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_proto2_nested_messages_proto_goTypes,
+		DependencyIndexes: file_proto2_nested_messages_proto_depIdxs,
+		MessageInfos:      file_proto2_nested_messages_proto_msgTypes,
+	}.Build()
+	File_proto2_nested_messages_proto = out.File
 	file_proto2_nested_messages_proto_rawDesc = nil
 	file_proto2_nested_messages_proto_goTypes = nil
 	file_proto2_nested_messages_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index 3bd3917..dfa61e5 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -5,7 +5,6 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -98,6 +97,11 @@
 }
 var file_proto2_proto2_proto_depIdxs = []int32{
 	0, // goproto.protoc.proto2.Message.m:type_name -> goproto.protoc.proto2.Message
+	1, // starting offset of method output_type sub-list
+	1, // starting offset of method input_type sub-list
+	1, // starting offset of extension type_name sub-list
+	1, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_proto2_proto2_proto_init() }
@@ -105,14 +109,19 @@
 	if File_proto2_proto2_proto != nil {
 		return
 	}
-	File_proto2_proto2_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_proto2_proto2_proto_rawDesc,
-		GoTypes:            file_proto2_proto2_proto_goTypes,
-		DependencyIndexes:  file_proto2_proto2_proto_depIdxs,
-		MessageOutputTypes: file_proto2_proto2_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto2_proto2_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_proto2_proto2_proto_goTypes,
+		DependencyIndexes: file_proto2_proto2_proto_depIdxs,
+		MessageInfos:      file_proto2_proto2_proto_msgTypes,
+	}.Build()
+	File_proto2_proto2_proto = out.File
 	file_proto2_proto2_proto_rawDesc = nil
 	file_proto2_proto2_proto_goTypes = nil
 	file_proto2_proto2_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index 7515d4a..97a38fc 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
 )
@@ -50,7 +50,7 @@
 }
 
 func (Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto3_enum_proto_enumTypes[0].Descriptor()
+	return file_proto3_enum_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x Enum) Number() protoreflect.EnumNumber {
@@ -89,25 +89,36 @@
 	return file_proto3_enum_proto_rawDescData
 }
 
-var file_proto3_enum_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_proto3_enum_proto_enumTypes = make([]prototype.Enum, 1)
 var file_proto3_enum_proto_goTypes = []interface{}{
 	(Enum)(0), // 0: goproto.protoc.proto3.Enum
 }
-var file_proto3_enum_proto_depIdxs = []int32{}
+var file_proto3_enum_proto_depIdxs = []int32{
+	0, // starting offset of method output_type sub-list
+	0, // starting offset of method input_type sub-list
+	0, // starting offset of extension type_name sub-list
+	0, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
+}
 
 func init() { file_proto3_enum_proto_init() }
 func file_proto3_enum_proto_init() {
 	if File_proto3_enum_proto != nil {
 		return
 	}
-	File_proto3_enum_proto = protoimpl.FileBuilder{
-		RawDescriptor:     file_proto3_enum_proto_rawDesc,
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto3_enum_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   0,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
 		GoTypes:           file_proto3_enum_proto_goTypes,
 		DependencyIndexes: file_proto3_enum_proto_depIdxs,
-		EnumOutputTypes:   file_proto3_enum_proto_enumTypes,
-		FilesRegistry:     protoregistry.GlobalFiles,
-		TypesRegistry:     protoregistry.GlobalTypes,
-	}.Init()
+	}.Build()
+	File_proto3_enum_proto = out.File
+	file_proto3_enum_proto_enumTypes = out.Enums
 	file_proto3_enum_proto_rawDesc = nil
 	file_proto3_enum_proto_goTypes = nil
 	file_proto3_enum_proto_depIdxs = nil
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index 81906e9..6023685 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -5,7 +5,7 @@
 
 import (
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-	protoregistry "google.golang.org/protobuf/reflect/protoregistry"
+	prototype "google.golang.org/protobuf/reflect/prototype"
 	protoiface "google.golang.org/protobuf/runtime/protoiface"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	sync "sync"
@@ -45,7 +45,7 @@
 }
 
 func (FieldTestMessage_Enum) Descriptor() protoreflect.EnumDescriptor {
-	return file_proto3_fields_proto_enumTypes[0].Descriptor()
+	return file_proto3_fields_proto_enumTypes[0].EnumDescriptor
 }
 
 func (x FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
@@ -577,7 +577,7 @@
 	return file_proto3_fields_proto_rawDescData
 }
 
-var file_proto3_fields_proto_enumTypes = make([]protoreflect.EnumType, 1)
+var file_proto3_fields_proto_enumTypes = make([]prototype.Enum, 1)
 var file_proto3_fields_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
 var file_proto3_fields_proto_goTypes = []interface{}{
 	(FieldTestMessage_Enum)(0),       // 0: goproto.protoc.proto3.FieldTestMessage.Enum
@@ -597,6 +597,11 @@
 	4, // goproto.protoc.proto3.FieldTestMessage.map_fixed64_enum:type_name -> goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry
 	5, // goproto.protoc.proto3.FieldTestMessage.MapStringMessageEntry.value:type_name -> goproto.protoc.proto3.FieldTestMessage.Message
 	0, // goproto.protoc.proto3.FieldTestMessage.MapFixed64EnumEntry.value:type_name -> goproto.protoc.proto3.FieldTestMessage.Enum
+	9, // starting offset of method output_type sub-list
+	9, // starting offset of method input_type sub-list
+	9, // starting offset of extension type_name sub-list
+	9, // starting offset of extension extendee sub-list
+	0, // starting offset of field type_name sub-list
 }
 
 func init() { file_proto3_fields_proto_init() }
@@ -604,15 +609,20 @@
 	if File_proto3_fields_proto != nil {
 		return
 	}
-	File_proto3_fields_proto = protoimpl.FileBuilder{
-		RawDescriptor:      file_proto3_fields_proto_rawDesc,
-		GoTypes:            file_proto3_fields_proto_goTypes,
-		DependencyIndexes:  file_proto3_fields_proto_depIdxs,
-		EnumOutputTypes:    file_proto3_fields_proto_enumTypes,
-		MessageOutputTypes: file_proto3_fields_proto_msgTypes,
-		FilesRegistry:      protoregistry.GlobalFiles,
-		TypesRegistry:      protoregistry.GlobalTypes,
-	}.Init()
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			RawDescriptor: file_proto3_fields_proto_rawDesc,
+			NumEnums:      1,
+			NumMessages:   5,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_proto3_fields_proto_goTypes,
+		DependencyIndexes: file_proto3_fields_proto_depIdxs,
+		MessageInfos:      file_proto3_fields_proto_msgTypes,
+	}.Build()
+	File_proto3_fields_proto = out.File
+	file_proto3_fields_proto_enumTypes = out.Enums
 	file_proto3_fields_proto_rawDesc = nil
 	file_proto3_fields_proto_goTypes = nil
 	file_proto3_fields_proto_depIdxs = nil