internal/impl: fix SetLazyValue
Since the internal body calls ExtensionType.ValueOf, it seems that the
intent is for lazyExtensionValue.value to store a:
func() protoreflect.Value
instead of a:
func() interface{}
This seems more apparent given that GetValue returns a pref.Value.
Change-Id: I1679fe56088c20d5c8d36360e75dd773850da4c2
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193757
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/codec_extension.go b/internal/impl/codec_extension.go
index c06cafd..f2dca63 100644
--- a/internal/impl/codec_extension.go
+++ b/internal/impl/codec_extension.go
@@ -137,7 +137,7 @@
// Deprecated: Do not use.
func (f *ExtensionField) SetLazyValue(fn func() interface{}) {
- f.lazy = &lazyExtensionValue{value: func() interface{} {
+ f.lazy = &lazyExtensionValue{value: func() pref.Value {
return f.typ.ValueOf(fn())
}}
}
@@ -145,7 +145,7 @@
type lazyExtensionValue struct {
once uint32 // atomically set if value is valid
mu sync.Mutex // protects value
- value interface{} // either the value itself or a func() interface{}
+ value interface{} // either a pref.Value itself or a func() pref.ValueOf
}
func (v *lazyExtensionValue) GetValue() pref.Value {