reflect/protoreflect: add Enum.Type and Message.Type
CL/174938 removed these methods in favor of a method that returned
only the descriptors. This CL adds back in the Type methods alongside
the Descriptor methods.
In a vast majority of protobuf usages, only the descriptor information
is needed. However, there is a small percentage that legitimately needs
the Go type information. We should provide both, but document that the
descriptor-only information is preferred.
Change-Id: Ia0a098997fb1bd009994940ae8ea5257ccd87cae
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/184578
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/message_test.go b/internal/impl/message_test.go
index 75c4460..0fb8ae0 100644
--- a/internal/impl/message_test.go
+++ b/internal/impl/message_test.go
@@ -963,6 +963,7 @@
}
func (e EnumProto2) Descriptor() pref.EnumDescriptor { return enumProto2Type.Descriptor() }
+func (e EnumProto2) Type() pref.EnumType { return enumProto2Type }
func (e EnumProto2) Enum() *EnumProto2 { return &e }
func (e EnumProto2) Number() pref.EnumNumber { return pref.EnumNumber(e) }
@@ -979,6 +980,7 @@
}
func (e EnumProto3) Descriptor() pref.EnumDescriptor { return enumProto3Type.Descriptor() }
+func (e EnumProto3) Type() pref.EnumType { return enumProto3Type }
func (e EnumProto3) Enum() *EnumProto3 { return &e }
func (e EnumProto3) Number() pref.EnumNumber { return pref.EnumNumber(e) }