summaryrefslogtreecommitdiffstats
path: root/vendor/google.golang.org/protobuf/internal/encoding/messageset
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/google.golang.org/protobuf/internal/encoding/messageset')
-rw-r--r--vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go33
1 files changed, 8 insertions, 25 deletions
diff --git a/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go b/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
index b1eeea50..c1866f3c 100644
--- a/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
+++ b/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
@@ -11,10 +11,9 @@ import (
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/errors"
pref "google.golang.org/protobuf/reflect/protoreflect"
- preg "google.golang.org/protobuf/reflect/protoregistry"
)
-// The MessageSet wire format is equivalent to a message defiend as follows,
+// The MessageSet wire format is equivalent to a message defined as follows,
// where each Item defines an extension field with a field number of 'type_id'
// and content of 'message'. MessageSet extensions must be non-repeated message
// fields.
@@ -48,33 +47,17 @@ func IsMessageSet(md pref.MessageDescriptor) bool {
return ok && xmd.IsMessageSet()
}
-// IsMessageSetExtension reports this field extends a MessageSet.
+// IsMessageSetExtension reports this field properly extends a MessageSet.
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
- if fd.Name() != ExtensionName {
+ switch {
+ case fd.Name() != ExtensionName:
return false
- }
- if fd.FullName().Parent() != fd.Message().FullName() {
+ case !IsMessageSet(fd.ContainingMessage()):
+ return false
+ case fd.FullName().Parent() != fd.Message().FullName():
return false
}
- return IsMessageSet(fd.ContainingMessage())
-}
-
-// FindMessageSetExtension locates a MessageSet extension field by name.
-// In text and JSON formats, the extension name used is the message itself.
-// The extension field name is derived by appending ExtensionName.
-func FindMessageSetExtension(r preg.ExtensionTypeResolver, s pref.FullName) (pref.ExtensionType, error) {
- name := s.Append(ExtensionName)
- xt, err := r.FindExtensionByName(name)
- if err != nil {
- if err == preg.NotFound {
- return nil, err
- }
- return nil, errors.Wrap(err, "%q", name)
- }
- if !IsMessageSetExtension(xt.TypeDescriptor()) {
- return nil, preg.NotFound
- }
- return xt, nil
+ return true
}
// SizeField returns the size of a MessageSet item field containing an extension