all: tests, tweaks for lazy extension decoding
Add a test to confirm that extensions are lazily decoded when we expect.
Drop the UnmarshalDefaultResolver flag. I added it thinking for some
reason that internal/impl couldn't depend on protoregistry; since it can
(and does), it's simpler to just test if the resolver is the expected
value.
Use a default set of options when lazily unmarshaling extensions.
Change-Id: Ied7666ffdc3bf90630260a80c9568d9a945048bc
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218038
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/impl/decode.go b/internal/impl/decode.go
index 0fffad3..a2993d4 100644
--- a/internal/impl/decode.go
+++ b/internal/impl/decode.go
@@ -30,9 +30,11 @@
func (o unmarshalOptions) DiscardUnknown() bool { return o.Flags&piface.UnmarshalDiscardUnknown != 0 }
func (o unmarshalOptions) IsDefault() bool {
- // The UnmarshalDefaultResolver flag indicates that we're using the default resolver.
- // No other flag bit should be set.
- return o.Flags == piface.UnmarshalDefaultResolver
+ return o.Flags == 0 && o.Resolver == preg.GlobalTypes
+}
+
+var lazyUnmarshalOptions = unmarshalOptions{
+ Resolver: preg.GlobalTypes,
}
type unmarshalOutput struct {