all: refactor extensions, add proto.GetExtension etc.
Change protoiface.ExtensionDescV1 to implement protoreflect.ExtensionType.
ExtensionDescV1's Name field conflicts with the Descriptor Name method,
so change the protoreflect.{Message,Enum,Extension}Type types to no
longer implement the corresponding Descriptor interface. This also leads
to a clearer distinction between the two types.
Introduce a protoreflect.ExtensionTypeDescriptor type which bridges
between ExtensionType and ExtensionDescriptor.
Add extension accessor functions to the proto package:
proto.{Has,Clear,Get,Set}Extension. These functions take a
protoreflect.ExtensionType parameter, which allows writing the
same function call using either the old or new API:
proto.GetExtension(message, somepb.E_ExtensionFoo)
Fixes golang/protobuf#908
Change-Id: Ibc65d12a46666297849114fd3aefbc4a597d9f08
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/189199
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/testing/prototest/prototest_test.go b/testing/prototest/prototest_test.go
index a95ac0b..00df3a6 100644
--- a/testing/prototest/prototest_test.go
+++ b/testing/prototest/prototest_test.go
@@ -10,9 +10,12 @@
"google.golang.org/protobuf/internal/flags"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/runtime/protoimpl"
"google.golang.org/protobuf/testing/prototest"
irregularpb "google.golang.org/protobuf/internal/testprotos/irregular"
+ legacypb "google.golang.org/protobuf/internal/testprotos/legacy"
+ legacy1pb "google.golang.org/protobuf/internal/testprotos/legacy/proto2.v0.0.0-20160225-2fc053c5"
testpb "google.golang.org/protobuf/internal/testprotos/test"
_ "google.golang.org/protobuf/internal/testprotos/test/weak1"
_ "google.golang.org/protobuf/internal/testprotos/test/weak2"
@@ -26,6 +29,8 @@
(*testpb.TestRequired)(nil),
(*irregularpb.Message)(nil),
(*testpb.TestAllExtensions)(nil),
+ (*legacypb.Legacy)(nil),
+ protoimpl.X.MessageOf((*legacy1pb.Message)(nil)).Interface(),
}
if flags.Proto1Legacy {
ms = append(ms, (*testpb.TestWeak)(nil))