Просмотр исходного кода

encoding/jsonpb: remove dependency on descriptor proto

Keeping this consistent with textpb - golang.org/cl/168439.

Change-Id: Ie4c57615f4ac5eaf6b3836edaf7ae2082ebaae64
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171240
Reviewed-by: Damien Neil <dneil@google.com>
Herbie Ong 6 лет назад
Родитель
Сommit
89193ac602
1 измененных файлов с 2 добавлено и 11 удалено
  1. 2 11
      encoding/jsonpb/encode.go

+ 2 - 11
encoding/jsonpb/encode.go

@@ -15,8 +15,6 @@ import (
 	"github.com/golang/protobuf/v2/proto"
 	pref "github.com/golang/protobuf/v2/reflect/protoreflect"
 	"github.com/golang/protobuf/v2/reflect/protoregistry"
-
-	descpb "github.com/golang/protobuf/v2/types/descriptor"
 )
 
 // Marshal writes the given proto.Message in JSON format using default options.
@@ -337,13 +335,6 @@ func isMessageSetExtension(xt pref.ExtensionType) bool {
 	if xt.FullName().Parent() != mt.FullName() {
 		return false
 	}
-	xmt := xt.ExtendedType()
-	if xmt.Fields().Len() != 0 {
-		return false
-	}
-	opt := xmt.Options().(*descpb.MessageOptions)
-	if opt == nil {
-		return false
-	}
-	return opt.GetMessageSetWireFormat()
+	xmt, ok := xt.ExtendedType().(interface{ IsMessageSet() bool })
+	return ok && xmt.IsMessageSet()
 }