all: move v1 types over to the v2 repository

As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.

For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.

We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.

Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.

CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.

Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/cmd/protoc-gen-go-grpc/testdata/go.mod b/cmd/protoc-gen-go-grpc/testdata/go.mod
deleted file mode 100644
index 4509a7d..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/go.mod
+++ /dev/null
@@ -1,9 +0,0 @@
-module github.com/golang/protobuf/v2/cmd/protoc-gen-go-grpc/testdata
-
-require (
-	github.com/golang/protobuf v1.2.1-0.20190311234659-51c19b98ee31
-	github.com/golang/protobuf/v2 v2.0.0
-	google.golang.org/grpc v1.19.0
-)
-
-replace github.com/golang/protobuf/v2 => ../../..
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index 95e6611..cfa9e41 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -27,9 +27,14 @@
 )
 
 const (
-	mathPackage     = protogen.GoImportPath("math")
-	protoPackage    = protogen.GoImportPath("github.com/golang/protobuf/proto")
-	protoapiPackage = protogen.GoImportPath("github.com/golang/protobuf/protoapi")
+	mathPackage          = protogen.GoImportPath("math")
+	reflectPackage       = protogen.GoImportPath("reflect")
+	protoPackage         = protogen.GoImportPath("github.com/golang/protobuf/proto")
+	protoifacePackage    = protogen.GoImportPath("github.com/golang/protobuf/v2/runtime/protoiface")
+	protoimplPackage     = protogen.GoImportPath("github.com/golang/protobuf/v2/runtime/protoimpl")
+	protoreflectPackage  = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/protoreflect")
+	protoregistryPackage = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/protoregistry")
+	prototypePackage     = protogen.GoImportPath("github.com/golang/protobuf/v2/internal/prototype")
 )
 
 type fileInfo struct {
@@ -46,28 +51,6 @@
 	allExtensions    []*protogen.Extension
 }
 
-// protoPackage returns the package to import, which is either the protoPackage
-// or the protoapiPackage constant.
-//
-// This special casing exists because we are unable to move InternalMessageInfo
-// to protoapi since the implementation behind that logic is heavy and
-// too intricately connected to other parts of the proto package.
-// The descriptor proto is special in that it avoids using InternalMessageInfo
-// so that it is able to depend solely on protoapi and break its dependency
-// on the proto package. It is still semantically correct for descriptor to
-// avoid using InternalMessageInfo, but it does incur some performance penalty.
-// This is acceptable for descriptor, which is a single proto file and is not
-// known to be in the hot path for any code.
-//
-// TODO: Remove this special-casing when the table-driven implementation has
-// been ported over to v2.
-func (f *fileInfo) protoPackage() protogen.GoImportPath {
-	if isDescriptor(f.File) {
-		return protoapiPackage
-	}
-	return protoPackage
-}
-
 // GenerateFile generates the contents of a .pb.go file.
 func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.GeneratedFile {
 	filename := file.GeneratedFilenamePrefix + ".pb.go"
@@ -428,7 +411,7 @@
 			tags = append(tags, `protobuf_messageset:"1"`)
 		}
 		tags = append(tags, `json:"-"`)
-		g.P(f.protoPackage().Ident("XXX_InternalExtensions"), " `", strings.Join(tags, " "), "`")
+		g.P("XXX_InternalExtensions ", protoimplPackage.Ident("ExtensionFieldsV1"), " `", strings.Join(tags, " "), "`")
 	}
 	g.P("XXX_unrecognized []byte `json:\"-\"`")
 	g.P("XXX_sizecache int32 `json:\"-\"`")
@@ -444,7 +427,7 @@
 	if isDescriptor(f.File) {
 		g.P("func (m *", message.GoIdent, ") String() string { return ", protoimplPackage.Ident("X"), ".MessageStringOf(m) }")
 	} else {
-		g.P("func (m *", message.GoIdent, ") String() string { return ", f.protoPackage().Ident("CompactTextString"), "(m) }")
+		g.P("func (m *", message.GoIdent, ") String() string { return ", protoPackage.Ident("CompactTextString"), "(m) }")
 	}
 	// ProtoMessage
 	g.P("func (*", message.GoIdent, ") ProtoMessage() {}")
@@ -461,7 +444,7 @@
 
 	// ExtensionRangeArray
 	if extranges := message.Desc.ExtensionRanges(); extranges.Len() > 0 {
-		protoExtRange := f.protoPackage().Ident("ExtensionRange")
+		protoExtRange := protoifacePackage.Ident("ExtensionRangeV1")
 		extRangeVar := "extRange_" + message.GoIdent.GoName
 		g.P("var ", extRangeVar, " = []", protoExtRange, " {")
 		for i := 0; i < extranges.Len(); i++ {
@@ -696,7 +679,7 @@
 		return
 	}
 
-	g.P("var ", extDecsVarName(f), " = []", f.protoPackage().Ident("ExtensionDesc"), "{")
+	g.P("var ", extDecsVarName(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",
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index c2f429e..b9068dc 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -23,14 +23,6 @@
 // in the proto package that was introduced in a later version.
 const minimumVersion = 0
 
-const (
-	reflectPackage       = protogen.GoImportPath("reflect")
-	protoimplPackage     = protogen.GoImportPath("github.com/golang/protobuf/v2/runtime/protoimpl")
-	protoreflectPackage  = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/protoreflect")
-	protoregistryPackage = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/protoregistry")
-	prototypePackage     = protogen.GoImportPath("github.com/golang/protobuf/v2/internal/prototype")
-)
-
 // TODO: Add support for proto options.
 
 func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo) {
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 3d15a81..3b290a6 100644
--- a/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/base/base.pb.go
@@ -6,16 +6,17 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
 )
 
 type BaseMessage struct {
-	Field                        *string  `protobuf:"bytes,1,opt,name=field" json:"field,omitempty"`
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	Field                  *string                     `protobuf:"bytes,1,opt,name=field" json:"field,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *BaseMessage) ProtoReflect() protoreflect.Message {
@@ -30,13 +31,13 @@
 	return xxx_File_extensions_base_base_proto_rawdesc_gzipped, []int{0}
 }
 
-var extRange_BaseMessage = []proto.ExtensionRange{
+var extRange_BaseMessage = []protoiface.ExtensionRangeV1{
 	{Start: 4, End: 9},
 	{Start: 16, End: 536870911},
 }
 
 // Deprecated: Use BaseMessage.ProtoReflect.Type.ExtensionRanges instead.
-func (*BaseMessage) ExtensionRangeArray() []proto.ExtensionRange {
+func (*BaseMessage) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_BaseMessage
 }
 
@@ -66,10 +67,10 @@
 }
 
 type MessageSetWireFormatMessage struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `protobuf_messageset:"1" json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `protobuf_messageset:"1" json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *MessageSetWireFormatMessage) ProtoReflect() protoreflect.Message {
@@ -84,12 +85,12 @@
 	return xxx_File_extensions_base_base_proto_rawdesc_gzipped, []int{1}
 }
 
-var extRange_MessageSetWireFormatMessage = []proto.ExtensionRange{
+var extRange_MessageSetWireFormatMessage = []protoiface.ExtensionRangeV1{
 	{Start: 100, End: 2147483646},
 }
 
 // Deprecated: Use MessageSetWireFormatMessage.ProtoReflect.Type.ExtensionRanges instead.
-func (*MessageSetWireFormatMessage) ExtensionRangeArray() []proto.ExtensionRange {
+func (*MessageSetWireFormatMessage) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_MessageSetWireFormatMessage
 }
 
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 80459cb..5cfb7e6 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -8,6 +8,7 @@
 	base "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/base"
 	extra "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/extra"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
 )
@@ -229,10 +230,10 @@
 
 // An extension of an extension.
 type Extendable struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *Extendable) ProtoReflect() protoreflect.Message {
@@ -247,12 +248,12 @@
 	return xxx_File_extensions_ext_ext_proto_rawdesc_gzipped, []int{4}
 }
 
-var extRange_Extendable = []proto.ExtensionRange{
+var extRange_Extendable = []protoiface.ExtensionRangeV1{
 	{Start: 1, End: 536870911},
 }
 
 // Deprecated: Use Extendable.ProtoReflect.Type.ExtensionRanges instead.
-func (*Extendable) ExtensionRangeArray() []proto.ExtensionRange {
+func (*Extendable) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_Extendable
 }
 
@@ -387,7 +388,7 @@
 
 var xxx_messageInfo_ExtendingMessage_ExtendingMessageSubmessage proto.InternalMessageInfo
 
-var xxx_File_extensions_ext_ext_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_extensions_ext_ext_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*base.BaseMessage)(nil),
 		ExtensionType: (*bool)(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 5975879..446c804 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -6,6 +6,7 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	descriptor "github.com/golang/protobuf/v2/types/descriptor"
 	reflect "reflect"
@@ -79,7 +80,7 @@
 
 var xxx_messageInfo_Message proto.InternalMessageInfo
 
-var xxx_File_extensions_proto3_ext3_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_extensions_proto3_ext3_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*descriptor.MessageOptions)(nil),
 		ExtensionType: (*bool)(nil),
diff --git a/cmd/protoc-gen-go/testdata/go.mod b/cmd/protoc-gen-go/testdata/go.mod
deleted file mode 100644
index b2d4d5e..0000000
--- a/cmd/protoc-gen-go/testdata/go.mod
+++ /dev/null
@@ -1,8 +0,0 @@
-module github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata
-
-require (
-	github.com/golang/protobuf v1.2.1-0.20190311234659-51c19b98ee31
-	github.com/golang/protobuf/v2 v2.0.0
-)
-
-replace github.com/golang/protobuf/v2 => ../../..
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 bad05bc..cc4f585 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
@@ -7,6 +7,7 @@
 	proto "github.com/golang/protobuf/proto"
 	sub2 "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub2"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	math "math"
 	reflect "reflect"
@@ -163,11 +164,11 @@
 	// Types that are valid to be assigned to OneofField:
 	//	*M_OneofInt32
 	//	*M_OneofInt64
-	OneofField                   isM_OneofField `protobuf_oneof:"oneof_field"`
-	XXX_NoUnkeyedLiteral         struct{}       `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	OneofField             isM_OneofField              `protobuf_oneof:"oneof_field"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *M) ProtoReflect() protoreflect.Message {
@@ -182,12 +183,12 @@
 	return xxx_File_import_public_sub_a_proto_rawdesc_gzipped, []int{0}
 }
 
-var extRange_M = []proto.ExtensionRange{
+var extRange_M = []protoiface.ExtensionRangeV1{
 	{Start: 100, End: 536870911},
 }
 
 // Deprecated: Use M.ProtoReflect.Type.ExtensionRanges instead.
-func (*M) ExtensionRangeArray() []proto.ExtensionRange {
+func (*M) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_M
 }
 
@@ -372,7 +373,7 @@
 	}
 }
 
-var xxx_File_import_public_sub_a_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_import_public_sub_a_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*M)(nil),
 		ExtensionType: (*string)(nil),
diff --git a/encoding/jsonpb/decode_test.go b/encoding/jsonpb/decode_test.go
index 2ef81cd..2552275 100644
--- a/encoding/jsonpb/decode_test.go
+++ b/encoding/jsonpb/decode_test.go
@@ -9,13 +9,13 @@
 	"testing"
 
 	protoV1 "github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/encoding/jsonpb"
 	"github.com/golang/protobuf/v2/encoding/testprotos/pb2"
 	"github.com/golang/protobuf/v2/encoding/testprotos/pb3"
 	"github.com/golang/protobuf/v2/internal/scalar"
 	"github.com/golang/protobuf/v2/proto"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	"github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
 func init() {
@@ -42,7 +42,7 @@
 	registerExtension(pb2.E_FakeMessageSetExtension_MessageSetExtension)
 }
 
-func registerExtension(xd *protoapi.ExtensionDesc) {
+func registerExtension(xd *protoiface.ExtensionDescV1) {
 	preg.GlobalTypes.Register(xd.Type)
 }
 
diff --git a/encoding/jsonpb/encode_test.go b/encoding/jsonpb/encode_test.go
index 13596e0..74dd570 100644
--- a/encoding/jsonpb/encode_test.go
+++ b/encoding/jsonpb/encode_test.go
@@ -10,13 +10,13 @@
 	"strings"
 	"testing"
 
-	"github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/encoding/jsonpb"
 	"github.com/golang/protobuf/v2/internal/encoding/pack"
 	"github.com/golang/protobuf/v2/internal/encoding/wire"
 	"github.com/golang/protobuf/v2/internal/scalar"
 	"github.com/golang/protobuf/v2/proto"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	"github.com/golang/protobuf/v2/runtime/protoiface"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 
@@ -45,7 +45,7 @@
 	return p
 }
 
-func setExtension(m proto.Message, xd *protoapi.ExtensionDesc, val interface{}) {
+func setExtension(m proto.Message, xd *protoiface.ExtensionDescV1, val interface{}) {
 	knownFields := m.ProtoReflect().KnownFields()
 	extTypes := knownFields.ExtensionTypes()
 	extTypes.Register(xd.Type)
diff --git a/encoding/testprotos/pb2/test.pb.go b/encoding/testprotos/pb2/test.pb.go
index 68ce05e..fdbd57e 100644
--- a/encoding/testprotos/pb2/test.pb.go
+++ b/encoding/testprotos/pb2/test.pb.go
@@ -6,6 +6,7 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	known "github.com/golang/protobuf/v2/types/known"
 	reflect "reflect"
@@ -849,13 +850,13 @@
 }
 
 type Extensions struct {
-	OptString                    *string  `protobuf:"bytes,1,opt,name=opt_string,json=optString" json:"opt_string,omitempty"`
-	OptBool                      *bool    `protobuf:"varint,101,opt,name=opt_bool,json=optBool" json:"opt_bool,omitempty"`
-	OptInt32                     *int32   `protobuf:"varint,2,opt,name=opt_int32,json=optInt32" json:"opt_int32,omitempty"`
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	OptString              *string                     `protobuf:"bytes,1,opt,name=opt_string,json=optString" json:"opt_string,omitempty"`
+	OptBool                *bool                       `protobuf:"varint,101,opt,name=opt_bool,json=optBool" json:"opt_bool,omitempty"`
+	OptInt32               *int32                      `protobuf:"varint,2,opt,name=opt_int32,json=optInt32" json:"opt_int32,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *Extensions) ProtoReflect() protoreflect.Message {
@@ -870,12 +871,12 @@
 	return xxx_File_pb2_test_proto_rawdesc_gzipped, []int{9}
 }
 
-var extRange_Extensions = []proto.ExtensionRange{
+var extRange_Extensions = []protoiface.ExtensionRangeV1{
 	{Start: 20, End: 100},
 }
 
 // Deprecated: Use Extensions.ProtoReflect.Type.ExtensionRanges instead.
-func (*Extensions) ExtensionRangeArray() []proto.ExtensionRange {
+func (*Extensions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_Extensions
 }
 
@@ -955,10 +956,10 @@
 var xxx_messageInfo_ExtensionsContainer proto.InternalMessageInfo
 
 type MessageSet struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `protobuf_messageset:"1" json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `protobuf_messageset:"1" json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *MessageSet) ProtoReflect() protoreflect.Message {
@@ -973,12 +974,12 @@
 	return xxx_File_pb2_test_proto_rawdesc_gzipped, []int{11}
 }
 
-var extRange_MessageSet = []proto.ExtensionRange{
+var extRange_MessageSet = []protoiface.ExtensionRangeV1{
 	{Start: 4, End: 2147483646},
 }
 
 // Deprecated: Use MessageSet.ProtoReflect.Type.ExtensionRanges instead.
-func (*MessageSet) ExtensionRangeArray() []proto.ExtensionRange {
+func (*MessageSet) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_MessageSet
 }
 
@@ -1045,10 +1046,10 @@
 }
 
 type FakeMessageSet struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *FakeMessageSet) ProtoReflect() protoreflect.Message {
@@ -1063,12 +1064,12 @@
 	return xxx_File_pb2_test_proto_rawdesc_gzipped, []int{13}
 }
 
-var extRange_FakeMessageSet = []proto.ExtensionRange{
+var extRange_FakeMessageSet = []protoiface.ExtensionRangeV1{
 	{Start: 4, End: 536870911},
 }
 
 // Deprecated: Use FakeMessageSet.ProtoReflect.Type.ExtensionRanges instead.
-func (*FakeMessageSet) ExtensionRangeArray() []proto.ExtensionRange {
+func (*FakeMessageSet) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_FakeMessageSet
 }
 
@@ -1455,7 +1456,7 @@
 	return 0
 }
 
-var xxx_File_pb2_test_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_pb2_test_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*Extensions)(nil),
 		ExtensionType: (*bool)(nil),
diff --git a/encoding/textpb/decode_test.go b/encoding/textpb/decode_test.go
index b463023..44f4daf 100644
--- a/encoding/textpb/decode_test.go
+++ b/encoding/textpb/decode_test.go
@@ -9,12 +9,12 @@
 	"testing"
 
 	protoV1 "github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/encoding/textpb"
 	"github.com/golang/protobuf/v2/internal/legacy"
 	"github.com/golang/protobuf/v2/internal/scalar"
 	"github.com/golang/protobuf/v2/proto"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	"github.com/golang/protobuf/v2/runtime/protoiface"
 
 	"github.com/golang/protobuf/v2/encoding/testprotos/pb2"
 	"github.com/golang/protobuf/v2/encoding/testprotos/pb3"
@@ -45,7 +45,7 @@
 	registerExtension(pb2.E_FakeMessageSetExtension_MessageSetExtension)
 }
 
-func registerExtension(xd *protoapi.ExtensionDesc) {
+func registerExtension(xd *protoiface.ExtensionDescV1) {
 	xt := legacy.Export{}.ExtensionTypeFromDesc(xd)
 	preg.GlobalTypes.Register(xt)
 }
diff --git a/encoding/textpb/encode_test.go b/encoding/textpb/encode_test.go
index 2d7b7de..2654e05 100644
--- a/encoding/textpb/encode_test.go
+++ b/encoding/textpb/encode_test.go
@@ -10,7 +10,6 @@
 	"strings"
 	"testing"
 
-	"github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/encoding/textpb"
 	"github.com/golang/protobuf/v2/internal/detrand"
 	"github.com/golang/protobuf/v2/internal/encoding/pack"
@@ -18,6 +17,7 @@
 	"github.com/golang/protobuf/v2/internal/scalar"
 	"github.com/golang/protobuf/v2/proto"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	"github.com/golang/protobuf/v2/runtime/protoiface"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 
@@ -48,7 +48,7 @@
 	return p
 }
 
-func setExtension(m proto.Message, xd *protoapi.ExtensionDesc, val interface{}) {
+func setExtension(m proto.Message, xd *protoiface.ExtensionDescV1, val interface{}) {
 	knownFields := m.ProtoReflect().KnownFields()
 	extTypes := knownFields.ExtensionTypes()
 	extTypes.Register(xd.Type)
diff --git a/go.mod b/go.mod
deleted file mode 100644
index f201c04..0000000
--- a/go.mod
+++ /dev/null
@@ -1,6 +0,0 @@
-module github.com/golang/protobuf/v2
-
-require (
-	github.com/golang/protobuf v1.2.1-0.20190311233832-968e039ade03
-	github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42
-)
diff --git a/go.sum b/go.sum
deleted file mode 100644
index 9b14839..0000000
--- a/go.sum
+++ /dev/null
@@ -1,4 +0,0 @@
-github.com/golang/protobuf v1.2.1-0.20190311233832-968e039ade03 h1:9fMonKrK3A/zUsodyCLUQVFrEDPi/veKKdEemKA8H9k=
-github.com/golang/protobuf v1.2.1-0.20190311233832-968e039ade03/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42 h1:q3pnF5JFBNRz8sRD+IRj7Y6DMyYGTNqnZ9axTbSfoNI=
-github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
diff --git a/internal/fileinit/desc.go b/internal/fileinit/desc.go
index ec70095..e375e3f 100644
--- a/internal/fileinit/desc.go
+++ b/internal/fileinit/desc.go
@@ -13,13 +13,13 @@
 	"reflect"
 	"sync"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pragma "github.com/golang/protobuf/v2/internal/pragma"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
 	pfmt "github.com/golang/protobuf/v2/internal/typefmt"
 	"github.com/golang/protobuf/v2/proto"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
 // FileBuilder construct a protoreflect.FileDescriptor from the
@@ -102,7 +102,7 @@
 	// associated v2 ExtensionType and accessible via a pseudo-internal API.
 	// Also, the v2 ExtensionType will be stored into each v1 ExtensionDesc.
 	// If non-nil, len(LegacyExtensions) must equal len(ExtensionOutputTypes).
-	LegacyExtensions []papi.ExtensionDesc
+	LegacyExtensions []piface.ExtensionDescV1
 
 	// EnumOutputTypes is where Init stores all initialized enum types
 	// in "flattened ordering".
@@ -415,7 +415,7 @@
 		number       pref.FieldNumber
 		extendedType pref.MessageDescriptor
 
-		legacyDesc *papi.ExtensionDesc
+		legacyDesc *piface.ExtensionDescV1
 
 		lazy *extensionLazy // protected by fileDesc.once
 	}
@@ -475,7 +475,7 @@
 
 // ProtoLegacyExtensionDesc is a pseudo-internal API for allowing the v1 code
 // to be able to retrieve a v1 ExtensionDesc.
-func (xd *extensionDesc) ProtoLegacyExtensionDesc() *papi.ExtensionDesc { return xd.legacyDesc }
+func (xd *extensionDesc) ProtoLegacyExtensionDesc() *piface.ExtensionDescV1 { return xd.legacyDesc }
 
 type (
 	serviceDesc struct {
diff --git a/internal/impl/legacy_export.go b/internal/impl/legacy_export.go
index 8038333..44bb101 100644
--- a/internal/impl/legacy_export.go
+++ b/internal/impl/legacy_export.go
@@ -7,6 +7,7 @@
 import (
 	"encoding/binary"
 	"encoding/json"
+	"fmt"
 	"hash/crc32"
 	"math"
 
@@ -74,3 +75,19 @@
 	out = append(out, gzipFooter[:]...)
 	return out
 }
+
+// ExtensionFieldsOf returns an interface abstraction over various
+// internal representations of extension fields.
+//
+// TODO: Delete this once v1 no longer needs to interact with the low-level
+// extensions data structure.
+func (Export) ExtensionFieldsOf(p interface{}) legacyExtensionFieldsIface {
+	switch p := p.(type) {
+	case *map[int32]ExtensionFieldV1:
+		return (*legacyExtensionMap)(p)
+	case *ExtensionFieldsV1:
+		return (*legacyExtensionSyncMap)(p)
+	default:
+		panic(fmt.Sprintf("invalid extension fields type: %T", p))
+	}
+}
diff --git a/internal/impl/legact_export_test.go b/internal/impl/legacy_export_test.go
similarity index 100%
rename from internal/impl/legact_export_test.go
rename to internal/impl/legacy_export_test.go
diff --git a/internal/impl/legacy_extension.go b/internal/impl/legacy_extension.go
index 83d5e99..424ee3f 100644
--- a/internal/impl/legacy_extension.go
+++ b/internal/impl/legacy_extension.go
@@ -6,9 +6,10 @@
 
 import (
 	"reflect"
+	"sync"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
 func makeLegacyExtensionFieldsFunc(t reflect.Type) func(p *messageDataType) pref.KnownFields {
@@ -25,25 +26,25 @@
 }
 
 var (
-	extTypeA = reflect.TypeOf(map[int32]papi.ExtensionField(nil))
-	extTypeB = reflect.TypeOf(papi.XXX_InternalExtensions{})
+	extTypeA = reflect.TypeOf(map[int32]ExtensionFieldV1(nil))
+	extTypeB = reflect.TypeOf(ExtensionFieldsV1{})
 )
 
-func makeLegacyExtensionMapFunc(t reflect.Type) func(*messageDataType) papi.ExtensionFields {
+func makeLegacyExtensionMapFunc(t reflect.Type) func(*messageDataType) legacyExtensionFieldsIface {
 	fx1, _ := t.FieldByName("XXX_extensions")
 	fx2, _ := t.FieldByName("XXX_InternalExtensions")
 	switch {
 	case fx1.Type == extTypeA:
 		fieldOffset := offsetOf(fx1)
-		return func(p *messageDataType) papi.ExtensionFields {
+		return func(p *messageDataType) legacyExtensionFieldsIface {
 			v := p.p.Apply(fieldOffset).AsValueOf(fx1.Type).Interface()
-			return papi.ExtensionFieldsOf(v)
+			return Export{}.ExtensionFieldsOf(v)
 		}
 	case fx2.Type == extTypeB:
 		fieldOffset := offsetOf(fx2)
-		return func(p *messageDataType) papi.ExtensionFields {
+		return func(p *messageDataType) legacyExtensionFieldsIface {
 			v := p.p.Apply(fieldOffset).AsValueOf(fx2.Type).Interface()
-			return papi.ExtensionFieldsOf(v)
+			return Export{}.ExtensionFieldsOf(v)
 		}
 	default:
 		return nil
@@ -52,11 +53,11 @@
 
 type legacyExtensionFields struct {
 	mi *MessageType
-	x  papi.ExtensionFields
+	x  legacyExtensionFieldsIface
 }
 
 func (p legacyExtensionFields) Len() (n int) {
-	p.x.Range(func(num pref.FieldNumber, _ papi.ExtensionField) bool {
+	p.x.Range(func(num pref.FieldNumber, _ ExtensionFieldV1) bool {
 		if p.Has(pref.FieldNumber(num)) {
 			n++
 		}
@@ -119,7 +120,7 @@
 }
 
 func (p legacyExtensionFields) Range(f func(pref.FieldNumber, pref.Value) bool) {
-	p.x.Range(func(n pref.FieldNumber, x papi.ExtensionField) bool {
+	p.x.Range(func(n pref.FieldNumber, x ExtensionFieldV1) bool {
 		if p.Has(n) {
 			return f(n, p.Get(n))
 		}
@@ -143,7 +144,7 @@
 type legacyExtensionTypes legacyExtensionFields
 
 func (p legacyExtensionTypes) Len() (n int) {
-	p.x.Range(func(_ pref.FieldNumber, x papi.ExtensionField) bool {
+	p.x.Range(func(_ pref.FieldNumber, x ExtensionFieldV1) bool {
 		if x.Desc != nil {
 			n++
 		}
@@ -204,7 +205,7 @@
 }
 
 func (p legacyExtensionTypes) ByName(s pref.FullName) (t pref.ExtensionType) {
-	p.x.Range(func(_ pref.FieldNumber, x papi.ExtensionField) bool {
+	p.x.Range(func(_ pref.FieldNumber, x ExtensionFieldV1) bool {
 		if x.Desc != nil && x.Desc.Name == string(s) {
 			t = extensionTypeFromDesc(x.Desc)
 			return false
@@ -215,7 +216,7 @@
 }
 
 func (p legacyExtensionTypes) Range(f func(pref.ExtensionType) bool) {
-	p.x.Range(func(_ pref.FieldNumber, x papi.ExtensionField) bool {
+	p.x.Range(func(_ pref.FieldNumber, x ExtensionFieldV1) bool {
 		if x.Desc != nil {
 			if !f(extensionTypeFromDesc(x.Desc)) {
 				return false
@@ -225,8 +226,10 @@
 	})
 }
 
-func extensionDescFromType(typ pref.ExtensionType) *papi.ExtensionDesc {
-	if xt, ok := typ.(interface{ ProtoLegacyExtensionDesc() *papi.ExtensionDesc }); ok {
+func extensionDescFromType(typ pref.ExtensionType) *piface.ExtensionDescV1 {
+	if xt, ok := typ.(interface {
+		ProtoLegacyExtensionDesc() *piface.ExtensionDescV1
+	}); ok {
 		if desc := xt.ProtoLegacyExtensionDesc(); desc != nil {
 			return desc
 		}
@@ -234,9 +237,160 @@
 	return legacyWrapper.ExtensionDescFromType(typ)
 }
 
-func extensionTypeFromDesc(desc *papi.ExtensionDesc) pref.ExtensionType {
+func extensionTypeFromDesc(desc *piface.ExtensionDescV1) pref.ExtensionType {
 	if desc.Type != nil {
 		return desc.Type
 	}
 	return legacyWrapper.ExtensionTypeFromDesc(desc)
 }
+
+type legacyExtensionFieldsIface = interface {
+	Len() int
+	Has(pref.FieldNumber) bool
+	Get(pref.FieldNumber) ExtensionFieldV1
+	Set(pref.FieldNumber, ExtensionFieldV1)
+	Clear(pref.FieldNumber)
+	Range(f func(pref.FieldNumber, ExtensionFieldV1) bool)
+
+	// HasInit and Locker are used by v1 GetExtension to provide
+	// an artificial degree of concurrent safety.
+	HasInit() bool
+	sync.Locker
+}
+
+type ExtensionFieldV1 struct {
+	// TODO: Unexport these fields when v1 no longer interacts with the
+	// extension data structures directly.
+
+	// When an extension is stored in a message using SetExtension
+	// only desc and value are set. When the message is marshaled
+	// Raw will be set to the encoded form of the message.
+	//
+	// When a message is unmarshaled and contains extensions, each
+	// extension will have only Raw set. When such an extension is
+	// accessed using GetExtension (or GetExtensions) desc and value
+	// will be set.
+	Desc *piface.ExtensionDescV1 // TODO: switch to protoreflect.ExtensionType
+
+	// Value is a concrete value for the extension field. Let the type of
+	// Desc.ExtensionType be the "API type" and the type of Value be the
+	// "storage type". The API type and storage type are the same except:
+	//	* for scalars (except []byte), where the API type uses *T,
+	//	while the storage type uses T.
+	//	* for repeated fields, where the API type uses []T,
+	//	while the storage type uses *[]T.
+	//
+	// The reason for the divergence is so that the storage type more naturally
+	// matches what is expected of when retrieving the values through the
+	// protobuf reflection APIs.
+	//
+	// The Value may only be populated if Desc is also populated.
+	Value interface{} // TODO: switch to protoreflect.Value
+
+	// Raw is the raw encoded bytes for the extension field.
+	// It is possible for Raw to be populated irrespective of whether the
+	// other fields are populated.
+	Raw []byte // TODO: switch to protoreflect.RawFields
+}
+
+type ExtensionFieldsV1 legacyExtensionSyncMap
+type legacyExtensionSyncMap struct {
+	p *struct {
+		mu sync.Mutex
+		m  legacyExtensionMap
+	}
+}
+
+func (m legacyExtensionSyncMap) Len() int {
+	if m.p == nil {
+		return 0
+	}
+	return m.p.m.Len()
+}
+func (m legacyExtensionSyncMap) Has(n pref.FieldNumber) bool {
+	if m.p == nil {
+		return false
+	}
+	return m.p.m.Has(n)
+}
+func (m legacyExtensionSyncMap) Get(n pref.FieldNumber) ExtensionFieldV1 {
+	if m.p == nil {
+		return ExtensionFieldV1{}
+	}
+	return m.p.m.Get(n)
+}
+func (m *legacyExtensionSyncMap) Set(n pref.FieldNumber, x ExtensionFieldV1) {
+	if m.p == nil {
+		m.p = new(struct {
+			mu sync.Mutex
+			m  legacyExtensionMap
+		})
+	}
+	m.p.m.Set(n, x)
+}
+func (m legacyExtensionSyncMap) Clear(n pref.FieldNumber) {
+	if m.p == nil {
+		return
+	}
+	m.p.m.Clear(n)
+}
+func (m legacyExtensionSyncMap) Range(f func(pref.FieldNumber, ExtensionFieldV1) bool) {
+	if m.p == nil {
+		return
+	}
+	m.p.m.Range(f)
+}
+
+func (m legacyExtensionSyncMap) HasInit() bool {
+	return m.p != nil
+}
+func (m legacyExtensionSyncMap) Lock() {
+	m.p.mu.Lock()
+}
+func (m legacyExtensionSyncMap) Unlock() {
+	m.p.mu.Unlock()
+}
+
+type legacyExtensionMap map[int32]ExtensionFieldV1
+
+func (m legacyExtensionMap) Len() int {
+	return len(m)
+}
+func (m legacyExtensionMap) Has(n pref.FieldNumber) bool {
+	_, ok := m[int32(n)]
+	return ok
+}
+func (m legacyExtensionMap) Get(n pref.FieldNumber) ExtensionFieldV1 {
+	return m[int32(n)]
+}
+func (m *legacyExtensionMap) Set(n pref.FieldNumber, x ExtensionFieldV1) {
+	if *m == nil {
+		*m = make(map[int32]ExtensionFieldV1)
+	}
+	(*m)[int32(n)] = x
+}
+func (m *legacyExtensionMap) Clear(n pref.FieldNumber) {
+	delete(*m, int32(n))
+}
+func (m legacyExtensionMap) Range(f func(pref.FieldNumber, ExtensionFieldV1) bool) {
+	for n, x := range m {
+		if !f(pref.FieldNumber(n), x) {
+			return
+		}
+	}
+}
+
+var legacyExtensionLock sync.Mutex
+
+func (m legacyExtensionMap) HasInit() bool {
+	return m != nil
+}
+func (m legacyExtensionMap) Lock() {
+	if !m.HasInit() {
+		panic("cannot lock an uninitialized map")
+	}
+	legacyExtensionLock.Lock()
+}
+func (m legacyExtensionMap) Unlock() {
+	legacyExtensionLock.Unlock()
+}
diff --git a/internal/impl/legacy_test.go b/internal/impl/legacy_test.go
index 7fea32e..1bc5acf 100644
--- a/internal/impl/legacy_test.go
+++ b/internal/impl/legacy_test.go
@@ -10,13 +10,13 @@
 	"reflect"
 	"testing"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pack "github.com/golang/protobuf/v2/internal/encoding/pack"
 	pimpl "github.com/golang/protobuf/v2/internal/impl"
 	pragma "github.com/golang/protobuf/v2/internal/pragma"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
 	scalar "github.com/golang/protobuf/v2/internal/scalar"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 	cmp "github.com/google/go-cmp/cmp"
 	cmpopts "github.com/google/go-cmp/cmp/cmpopts"
 
@@ -28,15 +28,15 @@
 )
 
 type legacyTestMessage struct {
-	XXX_unrecognized []byte
-	papi.XXX_InternalExtensions
+	XXX_unrecognized       []byte
+	XXX_InternalExtensions pimpl.ExtensionFieldsV1
 }
 
 func (*legacyTestMessage) Reset()         {}
 func (*legacyTestMessage) String() string { return "" }
 func (*legacyTestMessage) ProtoMessage()  {}
-func (*legacyTestMessage) ExtensionRangeArray() []papi.ExtensionRange {
-	return []papi.ExtensionRange{{Start: 10, End: 20}, {Start: 40, End: 80}, {Start: 10000, End: 20000}}
+func (*legacyTestMessage) ExtensionRangeArray() []piface.ExtensionRangeV1 {
+	return []piface.ExtensionRangeV1{{Start: 10, End: 20}, {Start: 40, End: 80}, {Start: 10000, End: 20000}}
 }
 
 func TestLegacyUnknown(t *testing.T) {
@@ -440,7 +440,7 @@
 		}, (*EnumMessages)(nil)),
 	}
 
-	extensionDescs = []*papi.ExtensionDesc{{
+	extensionDescs = []*piface.ExtensionDescV1{{
 		ExtendedType:  (*legacyTestMessage)(nil),
 		ExtensionType: (*bool)(nil),
 		Field:         10000,
@@ -794,7 +794,7 @@
 			}
 
 			opts = cmp.Options{
-				cmpopts.IgnoreFields(papi.ExtensionDesc{}, "Type"),
+				cmpopts.IgnoreFields(piface.ExtensionDescV1{}, "Type"),
 			}
 			if diff := cmp.Diff(wantDesc, gotDesc, opts); diff != "" {
 				t.Errorf("ExtensionDesc mismatch (-want, +got):\n%v", diff)
diff --git a/internal/impl/legacy_unknown.go b/internal/impl/legacy_unknown.go
index b5c6840..759bab9 100644
--- a/internal/impl/legacy_unknown.go
+++ b/internal/impl/legacy_unknown.go
@@ -9,7 +9,6 @@
 	"reflect"
 	"sort"
 
-	papi "github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/internal/encoding/wire"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
 )
@@ -47,13 +46,13 @@
 // and also the extension field map.
 type legacyUnknownBytesAndExtensionMap struct {
 	u pref.UnknownFields
-	x papi.ExtensionFields
+	x legacyExtensionFieldsIface
 	r pref.FieldRanges
 }
 
 func (fs *legacyUnknownBytesAndExtensionMap) Len() int {
 	n := fs.u.Len()
-	fs.x.Range(func(_ pref.FieldNumber, x papi.ExtensionField) bool {
+	fs.x.Range(func(_ pref.FieldNumber, x ExtensionFieldV1) bool {
 		if len(x.Raw) > 0 {
 			n++
 		}
@@ -98,7 +97,7 @@
 		raw pref.RawFields
 	}
 	var xs []entry
-	fs.x.Range(func(n pref.FieldNumber, x papi.ExtensionField) bool {
+	fs.x.Range(func(n pref.FieldNumber, x ExtensionFieldV1) bool {
 		if len(x.Raw) > 0 {
 			xs = append(xs, entry{n, x.Raw})
 		}
diff --git a/internal/legacy/export.go b/internal/legacy/export.go
index adffa5f..054108a 100644
--- a/internal/legacy/export.go
+++ b/internal/legacy/export.go
@@ -7,10 +7,10 @@
 import (
 	"reflect"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pimpl "github.com/golang/protobuf/v2/internal/impl"
 	pvalue "github.com/golang/protobuf/v2/internal/value"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
 // Export is a zero-length named type that exists only to export a set of
@@ -37,11 +37,11 @@
 	return extensionTypeOf(d, reflect.TypeOf(t))
 }
 
-func (Export) ExtensionDescFromType(t pref.ExtensionType) *papi.ExtensionDesc {
+func (Export) ExtensionDescFromType(t pref.ExtensionType) *piface.ExtensionDescV1 {
 	return extensionDescFromType(t)
 }
 
-func (Export) ExtensionTypeFromDesc(d *papi.ExtensionDesc) pref.ExtensionType {
+func (Export) ExtensionTypeFromDesc(d *piface.ExtensionDescV1) pref.ExtensionType {
 	return extensionTypeFromDesc(d)
 }
 
diff --git a/internal/legacy/extension.go b/internal/legacy/extension.go
index 0c88c83..19205ea 100644
--- a/internal/legacy/extension.go
+++ b/internal/legacy/extension.go
@@ -9,16 +9,16 @@
 	"reflect"
 	"sync"
 
-	papi "github.com/golang/protobuf/protoapi"
 	ptag "github.com/golang/protobuf/v2/internal/encoding/tag"
 	pimpl "github.com/golang/protobuf/v2/internal/impl"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
 	pfmt "github.com/golang/protobuf/v2/internal/typefmt"
 	pvalue "github.com/golang/protobuf/v2/internal/value"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
-// extensionDescKey is a comparable version of protoapi.ExtensionDesc
+// extensionDescKey is a comparable version of protoiface.ExtensionDescV1
 // suitable for use as a key in a map.
 type extensionDescKey struct {
 	typeV2        pref.ExtensionType
@@ -30,7 +30,7 @@
 	filename      string
 }
 
-func extensionDescKeyOf(d *papi.ExtensionDesc) extensionDescKey {
+func extensionDescKeyOf(d *piface.ExtensionDescV1) extensionDescKey {
 	return extensionDescKey{
 		d.Type,
 		reflect.TypeOf(d.ExtendedType),
@@ -41,14 +41,16 @@
 
 var (
 	extensionTypeCache sync.Map // map[extensionDescKey]protoreflect.ExtensionType
-	extensionDescCache sync.Map // map[protoreflect.ExtensionType]*protoapi.ExtensionDesc
+	extensionDescCache sync.Map // map[protoreflect.ExtensionType]*protoiface.ExtensionDescV1
 )
 
 // extensionDescFromType converts a v2 protoreflect.ExtensionType to a
-// v1 protoapi.ExtensionDesc. The returned ExtensionDesc must not be mutated.
-func extensionDescFromType(t pref.ExtensionType) *papi.ExtensionDesc {
+// protoiface.ExtensionDescV1. The returned ExtensionDesc must not be mutated.
+func extensionDescFromType(t pref.ExtensionType) *piface.ExtensionDescV1 {
 	// Fast-path: check whether an extension desc is already nested within.
-	if t, ok := t.(interface{ ProtoLegacyExtensionDesc() *papi.ExtensionDesc }); ok {
+	if t, ok := t.(interface {
+		ProtoLegacyExtensionDesc() *piface.ExtensionDescV1
+	}); ok {
 		if d := t.ProtoLegacyExtensionDesc(); d != nil {
 			return d
 		}
@@ -57,11 +59,11 @@
 	// Fast-path: check the cache for whether this ExtensionType has already
 	// been converted to a legacy descriptor.
 	if d, ok := extensionDescCache.Load(t); ok {
-		return d.(*papi.ExtensionDesc)
+		return d.(*piface.ExtensionDescV1)
 	}
 
 	// Determine the parent type if possible.
-	var parent papi.Message
+	var parent piface.MessageV1
 	if mt, ok := t.ExtendedType().(pref.MessageType); ok {
 		// Create a new parent message and unwrap it if possible.
 		mv := mt.New().Interface()
@@ -72,7 +74,7 @@
 
 		// Check whether the message implements the legacy v1 Message interface.
 		mz := reflect.Zero(t).Interface()
-		if mz, ok := mz.(papi.Message); ok {
+		if mz, ok := mz.(piface.MessageV1); ok {
 			parent = mz
 		}
 	}
@@ -124,8 +126,8 @@
 		filename = fd.Path()
 	}
 
-	// Construct and return a v1 ExtensionDesc.
-	d := &papi.ExtensionDesc{
+	// Construct and return a ExtensionDescV1.
+	d := &piface.ExtensionDescV1{
 		Type:          t,
 		ExtendedType:  parent,
 		ExtensionType: reflect.Zero(extType).Interface(),
@@ -135,16 +137,16 @@
 		Filename:      filename,
 	}
 	if d, ok := extensionDescCache.LoadOrStore(t, d); ok {
-		return d.(*papi.ExtensionDesc)
+		return d.(*piface.ExtensionDescV1)
 	}
 	return d
 }
 
-// extensionTypeFromDesc converts a v1 protoapi.ExtensionDesc to a
+// extensionTypeFromDesc converts a protoiface.ExtensionDescV1 to a
 // v2 protoreflect.ExtensionType. The returned descriptor type takes ownership
 // of the input extension desc. The input must not be mutated so long as the
 // returned type is still in use.
-func extensionTypeFromDesc(d *papi.ExtensionDesc) pref.ExtensionType {
+func extensionTypeFromDesc(d *piface.ExtensionDescV1) pref.ExtensionType {
 	// Fast-path: check whether an extension type is already nested within.
 	if d.Type != nil {
 		return d.Type
diff --git a/internal/legacy/extension_test.go b/internal/legacy/extension_test.go
index 440863f..58af84b 100644
--- a/internal/legacy/extension_test.go
+++ b/internal/legacy/extension_test.go
@@ -7,10 +7,10 @@
 import (
 	"testing"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pimpl "github.com/golang/protobuf/v2/internal/impl"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 
 	// The legacy package must be imported prior to use of any legacy messages.
 	// TODO: Remove this when protoV1 registers these hooks for you.
@@ -20,15 +20,15 @@
 )
 
 type legacyTestMessage struct {
-	XXX_unrecognized []byte
-	papi.XXX_InternalExtensions
+	XXX_unrecognized       []byte
+	XXX_InternalExtensions pimpl.ExtensionFieldsV1
 }
 
 func (*legacyTestMessage) Reset()         {}
 func (*legacyTestMessage) String() string { return "" }
 func (*legacyTestMessage) ProtoMessage()  {}
-func (*legacyTestMessage) ExtensionRangeArray() []papi.ExtensionRange {
-	return []papi.ExtensionRange{{Start: 10000, End: 20000}}
+func (*legacyTestMessage) ExtensionRangeArray() []piface.ExtensionRangeV1 {
+	return []piface.ExtensionRangeV1{{Start: 10000, End: 20000}}
 }
 
 func mustMakeExtensionType(x *ptype.StandaloneExtension, v interface{}) pref.ExtensionType {
@@ -51,7 +51,7 @@
 		MessageType:  messageV1Type,
 		ExtendedType: parentType,
 	}, (*proto2_20180125.Message_ChildMessage)(nil))
-	wantDesc = &papi.ExtensionDesc{
+	wantDesc = &piface.ExtensionDescV1{
 		ExtendedType:  (*legacyTestMessage)(nil),
 		ExtensionType: (*proto2_20180125.Message_ChildMessage)(nil),
 		Field:         10007,
diff --git a/internal/testprotos/test/ext.pb.go b/internal/testprotos/test/ext.pb.go
index 0cb9ecf..065a38e 100644
--- a/internal/testprotos/test/ext.pb.go
+++ b/internal/testprotos/test/ext.pb.go
@@ -6,10 +6,11 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 )
 
-var xxx_File_test_ext_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_test_ext_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*TestAllExtensions)(nil),
 		ExtensionType: (*int32)(nil),
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index fe48501..24ef243 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -6,6 +6,7 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
 )
@@ -1213,10 +1214,10 @@
 var xxx_messageInfo_TestReservedFields proto.InternalMessageInfo
 
 type TestAllExtensions struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *TestAllExtensions) ProtoReflect() protoreflect.Message {
@@ -1231,12 +1232,12 @@
 	return xxx_File_test_test_proto_rawdesc_gzipped, []int{4}
 }
 
-var extRange_TestAllExtensions = []proto.ExtensionRange{
+var extRange_TestAllExtensions = []protoiface.ExtensionRangeV1{
 	{Start: 1, End: 536870911},
 }
 
 // Deprecated: Use TestAllExtensions.ProtoReflect.Type.ExtensionRanges instead.
-func (*TestAllExtensions) ExtensionRangeArray() []proto.ExtensionRange {
+func (*TestAllExtensions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_TestAllExtensions
 }
 
@@ -1595,7 +1596,7 @@
 	return 0
 }
 
-var xxx_File_test_test_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_test_test_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*TestAllExtensions)(nil),
 		ExtensionType: (*int32)(nil),
diff --git a/internal/value/convert.go b/internal/value/convert.go
index 9e40ac2..3bf5488 100644
--- a/internal/value/convert.go
+++ b/internal/value/convert.go
@@ -10,8 +10,8 @@
 	"fmt"
 	"reflect"
 
-	papi "github.com/golang/protobuf/protoapi"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 )
 
 // Unwrapper unwraps the value to the underlying value.
@@ -32,7 +32,7 @@
 	bytesType   = reflect.TypeOf([]byte(nil))
 
 	enumIfaceV2    = reflect.TypeOf((*pref.Enum)(nil)).Elem()
-	messageIfaceV1 = reflect.TypeOf((*papi.Message)(nil)).Elem()
+	messageIfaceV1 = reflect.TypeOf((*piface.MessageV1)(nil)).Elem()
 	messageIfaceV2 = reflect.TypeOf((*pref.ProtoMessage)(nil)).Elem()
 
 	byteType = reflect.TypeOf(byte(0))
@@ -62,9 +62,10 @@
 
 		ExtensionTypeOf(pref.ExtensionDescriptor, interface{}) pref.ExtensionType
 
-		// TODO: Remove these eventually. See the TODOs in protoapi.
-		ExtensionDescFromType(pref.ExtensionType) *papi.ExtensionDesc
-		ExtensionTypeFromDesc(*papi.ExtensionDesc) pref.ExtensionType
+		// TODO: Remove these eventually.
+		// See the TODOs in internal/impl/legacy_extension.go.
+		ExtensionDescFromType(pref.ExtensionType) *piface.ExtensionDescV1
+		ExtensionTypeFromDesc(*piface.ExtensionDescV1) pref.ExtensionType
 	}
 
 	LegacyEnum = interface {
diff --git a/reflect/protoregistry/registry_test.go b/reflect/protoregistry/registry_test.go
index ee9d742..a7cd2f2 100644
--- a/reflect/protoregistry/registry_test.go
+++ b/reflect/protoregistry/registry_test.go
@@ -12,11 +12,11 @@
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 
-	"github.com/golang/protobuf/protoapi"
 	"github.com/golang/protobuf/v2/internal/legacy"
 	ptype "github.com/golang/protobuf/v2/internal/prototype"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
 	preg "github.com/golang/protobuf/v2/reflect/protoregistry"
+	piface "github.com/golang/protobuf/v2/runtime/protoiface"
 
 	testpb "github.com/golang/protobuf/v2/reflect/protoregistry/testprotos"
 )
@@ -317,7 +317,7 @@
 	}
 }
 
-func extensionType(xd *protoapi.ExtensionDesc) pref.ExtensionType {
+func extensionType(xd *piface.ExtensionDescV1) pref.ExtensionType {
 	return legacy.Export{}.ExtensionTypeFromDesc(xd)
 }
 
diff --git a/reflect/protoregistry/testprotos/test.pb.go b/reflect/protoregistry/testprotos/test.pb.go
index 43e6db2..f204118 100644
--- a/reflect/protoregistry/testprotos/test.pb.go
+++ b/reflect/protoregistry/testprotos/test.pb.go
@@ -6,6 +6,7 @@
 import (
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
 )
@@ -149,10 +150,10 @@
 }
 
 type Message1 struct {
-	XXX_NoUnkeyedLiteral         struct{} `json:"-"`
-	proto.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized             []byte `json:"-"`
-	XXX_sizecache                int32  `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *Message1) ProtoReflect() protoreflect.Message {
@@ -167,12 +168,12 @@
 	return xxx_File_test_proto_rawdesc_gzipped, []int{0}
 }
 
-var extRange_Message1 = []proto.ExtensionRange{
+var extRange_Message1 = []protoiface.ExtensionRangeV1{
 	{Start: 10, End: 536870911},
 }
 
 // Deprecated: Use Message1.ProtoReflect.Type.ExtensionRanges instead.
-func (*Message1) ExtensionRangeArray() []proto.ExtensionRange {
+func (*Message1) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_Message1
 }
 
@@ -310,7 +311,7 @@
 	return false
 }
 
-var xxx_File_test_proto_extDescs = []proto.ExtensionDesc{
+var xxx_File_test_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*Message1)(nil),
 		ExtensionType: (*string)(nil),
diff --git a/runtime/protoiface/legacy.go b/runtime/protoiface/legacy.go
new file mode 100644
index 0000000..f153bcf
--- /dev/null
+++ b/runtime/protoiface/legacy.go
@@ -0,0 +1,71 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package protoiface contains types referenced by generated messages.
+//
+// WARNING: This package should only ever be imported by generated messages.
+// The compatibility agreement covers nothing except for functionality needed
+// to keep existing generated messages operational.
+package protoiface
+
+import (
+	"github.com/golang/protobuf/v2/reflect/protoreflect"
+)
+
+type MessageV1 interface {
+	Reset()
+	String() string
+	ProtoMessage()
+}
+
+type ExtensionRangeV1 struct {
+	Start, End int32 // both inclusive
+}
+
+type ExtensionDescV1 struct {
+	// Type is the descriptor type for the extension field using the v2 API.
+	// If populated, the information in this field takes precedence over
+	// all other fields in ExtensionDescV1.
+	Type protoreflect.ExtensionType
+
+	// ExtendedType is a typed nil-pointer to the parent message type that
+	// is being extended. It is possible for this to be unpopulated in v2
+	// since the message may no longer implement the MessageV1 interface.
+	//
+	// Deprecated: Use Type.ExtendedType instead.
+	ExtendedType MessageV1
+
+	// ExtensionType is zero value of the extension type.
+	//
+	// For historical reasons, reflect.TypeOf(ExtensionType) and Type.GoType
+	// may not be identical:
+	//	* for scalars (except []byte), where ExtensionType uses *T,
+	//	while Type.GoType uses T.
+	//	* for repeated fields, where ExtensionType uses []T,
+	//	while Type.GoType uses *[]T.
+	//
+	// Deprecated: Use Type.GoType instead.
+	ExtensionType interface{}
+
+	// Field is the field number of the extension.
+	//
+	// Deprecated: Use Type.Number instead.
+	Field int32 // field number
+
+	// Name is the fully qualified name of extension.
+	//
+	// Deprecated: Use Type.FullName instead.
+	Name string
+
+	// Tag is the protobuf struct tag used in the v1 API.
+	//
+	// Deprecated: Do not use.
+	Tag string
+
+	// Filename is the proto filename in which the extension is defined.
+	//
+	// Deprecated: Use Type.Parent to ascend to the top-most parent and use
+	// protoreflect.FileDescriptor.Path.
+	Filename string
+}
diff --git a/runtime/protoimpl/impl.go b/runtime/protoimpl/impl.go
index fdb2b6d..3c20296 100644
--- a/runtime/protoimpl/impl.go
+++ b/runtime/protoimpl/impl.go
@@ -40,4 +40,7 @@
 
 	MessageType = impl.MessageType
 	FileBuilder = fileinit.FileBuilder
+
+	ExtensionFieldV1  = impl.ExtensionFieldV1
+	ExtensionFieldsV1 = impl.ExtensionFieldsV1
 )
diff --git a/types/descriptor/descriptor.pb.go b/types/descriptor/descriptor.pb.go
index 484f1f2..0bd0862 100644
--- a/types/descriptor/descriptor.pb.go
+++ b/types/descriptor/descriptor.pb.go
@@ -4,10 +4,10 @@
 package descriptor_proto
 
 import (
-	protoapi "github.com/golang/protobuf/protoapi"
 	prototype "github.com/golang/protobuf/v2/internal/prototype"
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	reflect "reflect"
 )
@@ -647,11 +647,11 @@
 
 type ExtensionRangeOptions struct {
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *ExtensionRangeOptions) ProtoReflect() protoreflect.Message {
@@ -666,12 +666,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{3}
 }
 
-var extRange_ExtensionRangeOptions = []protoapi.ExtensionRange{
+var extRange_ExtensionRangeOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use ExtensionRangeOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*ExtensionRangeOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*ExtensionRangeOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_ExtensionRangeOptions
 }
 
@@ -1144,11 +1144,11 @@
 	RubyPackage *string `protobuf:"bytes,45,opt,name=ruby_package,json=rubyPackage" json:"ruby_package,omitempty"`
 	// The parser stores options it doesn't recognize here.
 	// See the documentation for the "Options" section above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *FileOptions) ProtoReflect() protoreflect.Message {
@@ -1163,12 +1163,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{10}
 }
 
-var extRange_FileOptions = []protoapi.ExtensionRange{
+var extRange_FileOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use FileOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*FileOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*FileOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_FileOptions
 }
 
@@ -1382,11 +1382,11 @@
 	// parser.
 	MapEntry *bool `protobuf:"varint,7,opt,name=map_entry,json=mapEntry" json:"map_entry,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *MessageOptions) ProtoReflect() protoreflect.Message {
@@ -1401,12 +1401,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{11}
 }
 
-var extRange_MessageOptions = []protoapi.ExtensionRange{
+var extRange_MessageOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use MessageOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*MessageOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*MessageOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_MessageOptions
 }
 
@@ -1510,11 +1510,11 @@
 	// For Google-internal migration only. Do not use.
 	Weak *bool `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *FieldOptions) ProtoReflect() protoreflect.Message {
@@ -1529,12 +1529,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{12}
 }
 
-var extRange_FieldOptions = []protoapi.ExtensionRange{
+var extRange_FieldOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use FieldOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*FieldOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*FieldOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_FieldOptions
 }
 
@@ -1595,11 +1595,11 @@
 
 type OneofOptions struct {
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *OneofOptions) ProtoReflect() protoreflect.Message {
@@ -1614,12 +1614,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{13}
 }
 
-var extRange_OneofOptions = []protoapi.ExtensionRange{
+var extRange_OneofOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use OneofOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*OneofOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*OneofOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_OneofOptions
 }
 
@@ -1640,11 +1640,11 @@
 	// is a formalization for deprecating enums.
 	Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *EnumOptions) ProtoReflect() protoreflect.Message {
@@ -1659,12 +1659,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{14}
 }
 
-var extRange_EnumOptions = []protoapi.ExtensionRange{
+var extRange_EnumOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use EnumOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*EnumOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*EnumOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_EnumOptions
 }
 
@@ -1698,11 +1698,11 @@
 	// this is a formalization for deprecating enum values.
 	Deprecated *bool `protobuf:"varint,1,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *EnumValueOptions) ProtoReflect() protoreflect.Message {
@@ -1717,12 +1717,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{15}
 }
 
-var extRange_EnumValueOptions = []protoapi.ExtensionRange{
+var extRange_EnumValueOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use EnumValueOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*EnumValueOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*EnumValueOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_EnumValueOptions
 }
 
@@ -1749,11 +1749,11 @@
 	// this is a formalization for deprecating services.
 	Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *ServiceOptions) ProtoReflect() protoreflect.Message {
@@ -1768,12 +1768,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{16}
 }
 
-var extRange_ServiceOptions = []protoapi.ExtensionRange{
+var extRange_ServiceOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use ServiceOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*ServiceOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*ServiceOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_ServiceOptions
 }
 
@@ -1801,11 +1801,11 @@
 	Deprecated       *bool                           `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"`
 	IdempotencyLevel *MethodOptions_IdempotencyLevel `protobuf:"varint,34,opt,name=idempotency_level,json=idempotencyLevel,enum=google.protobuf.MethodOptions_IdempotencyLevel,def=0" json:"idempotency_level,omitempty"`
 	// The parser stores options it doesn't recognize here. See above.
-	UninterpretedOption             []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
-	XXX_NoUnkeyedLiteral            struct{}               `json:"-"`
-	protoapi.XXX_InternalExtensions `json:"-"`
-	XXX_unrecognized                []byte `json:"-"`
-	XXX_sizecache                   int32  `json:"-"`
+	UninterpretedOption    []*UninterpretedOption      `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"`
+	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
+	XXX_unrecognized       []byte                      `json:"-"`
+	XXX_sizecache          int32                       `json:"-"`
 }
 
 func (m *MethodOptions) ProtoReflect() protoreflect.Message {
@@ -1820,12 +1820,12 @@
 	return xxx_File_google_protobuf_descriptor_proto_rawdesc_gzipped, []int{17}
 }
 
-var extRange_MethodOptions = []protoapi.ExtensionRange{
+var extRange_MethodOptions = []protoiface.ExtensionRangeV1{
 	{Start: 1000, End: 536870911},
 }
 
 // Deprecated: Use MethodOptions.ProtoReflect.Type.ExtensionRanges instead.
-func (*MethodOptions) ExtensionRangeArray() []protoapi.ExtensionRange {
+func (*MethodOptions) ExtensionRangeArray() []protoiface.ExtensionRangeV1 {
 	return extRange_MethodOptions
 }