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/legacy_enum.go b/internal/impl/legacy_enum.go
index e9603e4..3c24eb3 100644
--- a/internal/impl/legacy_enum.go
+++ b/internal/impl/legacy_enum.go
@@ -64,6 +64,9 @@
func (e *legacyEnumWrapper) Descriptor() pref.EnumDescriptor {
return e.pbTyp.Descriptor()
}
+func (e *legacyEnumWrapper) Type() pref.EnumType {
+ return e.pbTyp
+}
func (e *legacyEnumWrapper) Number() pref.EnumNumber {
return e.num
}