reflect/protoreflect: drop the ProtoEnum type
Drop the protoreflect.ProtoEnum type (containing a single method
returning a protoreflect.Enum) and make generated enum types
directly implement protoreflect.Enum instead.
Messages have a two-level type split (ProtoMessage and Message) to
minimize conflicts between reflection methods and field names. Enums
need no such split, since enums do not have fields and therefore have
no source of conflicts.
Change-Id: I2b6222e9404253e6bfef2217859e1b760ffcd29b
Reviewed-on: https://go-review.googlesource.com/c/156902
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index f1a3ce3..bb71643 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -25,15 +25,10 @@
TestAllTypes_NEG TestAllTypes_NestedEnum = -1
)
-type xxx_TestAllTypes_NestedEnum TestAllTypes_NestedEnum
-
-func (e TestAllTypes_NestedEnum) ProtoReflect() protoreflect.Enum {
- return (xxx_TestAllTypes_NestedEnum)(e)
-}
-func (e xxx_TestAllTypes_NestedEnum) Type() protoreflect.EnumType {
+func (e TestAllTypes_NestedEnum) Type() protoreflect.EnumType {
return xxx_Test_ProtoFile_EnumTypes[0]
}
-func (e xxx_TestAllTypes_NestedEnum) Number() protoreflect.EnumNumber {
+func (e TestAllTypes_NestedEnum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -1622,7 +1617,7 @@
var xxx_Test_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Test_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return TestAllTypes_NestedEnum(n)
},
),