internal/impl: unexport ExtensionField.Desc
CL/180577 removes direct access to the Desc field in v1.
Since the only way to access the type is through {Has,Get,Set}Type,
we can now unexport the field and change the underlying type.
Change-Id: I6cc7018d4326c17228ba579d6161c5fb3f6d4127
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/180578
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/codec_extension.go b/internal/impl/codec_extension.go
index 69d5a96..577f1df 100644
--- a/internal/impl/codec_extension.go
+++ b/internal/impl/codec_extension.go
@@ -10,7 +10,6 @@
"google.golang.org/protobuf/internal/encoding/wire"
pref "google.golang.org/protobuf/reflect/protoreflect"
- piface "google.golang.org/protobuf/runtime/protoiface"
)
type extensionFieldInfo struct {
@@ -46,9 +45,7 @@
}
type ExtensionField struct {
- // Desc is the descriptor information for the extension field.
- // It must be populated if value is populated.
- Desc *piface.ExtensionDescV1 // TODO: unexport and switch to protoreflect.ExtensionType
+ typ pref.ExtensionType
// value is either the value of GetValue,
// or a *lazyExtensionValue that then returns the value of GetValue.
@@ -56,13 +53,13 @@
}
func (f ExtensionField) HasType() bool {
- return f.Desc != nil
+ return f.typ != nil
}
func (f ExtensionField) GetType() pref.ExtensionType {
- return legacyExtensionTypeFromDesc(f.Desc)
+ return f.typ
}
func (f *ExtensionField) SetType(t pref.ExtensionType) {
- f.Desc = legacyExtensionDescFromType(t)
+ f.typ = t
}
// HasValue reports whether a value is set for the extension field.