Skip to content

Commit

Permalink
cmd/protoc-gen-go: remove name mangling for MessageSet extensions
Browse files Browse the repository at this point in the history
MessageSet are a proto1 feature only used by Google.
We no longer rely on the name mangling logic performed here,
so remove it.

Change-Id: I5d66ebd86875894632f0d0c1e9816ae47ee0d5f4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/242657
Reviewed-by: Herbie Ong <herbie@google.com>
  • Loading branch information
dsnet committed Jul 14, 2020
1 parent aabe152 commit e7c3f89
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
9 changes: 1 addition & 8 deletions cmd/protoc-gen-go/internal_gengo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"unicode/utf8"

"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/encoding/tag"
"google.golang.org/protobuf/internal/genid"
"google.golang.org/protobuf/internal/version"
Expand Down Expand Up @@ -735,12 +734,6 @@ func genExtensions(g *protogen.GeneratedFile, f *fileInfo) {

g.P("var ", extensionTypesVarName(f), " = []", protoimplPackage.Ident("ExtensionInfo"), "{")
for _, x := range f.allExtensions {
// For MessageSet extensions, the name used is the parent message.
name := x.Desc.FullName()
if messageset.IsMessageSetExtension(x.Desc) {
name = name.Parent()
}

g.P("{")
g.P("ExtendedType: (*", x.Extendee.GoIdent, ")(nil),")
goType, pointer := fieldGoType(g, f, x.Extension)
Expand All @@ -749,7 +742,7 @@ func genExtensions(g *protogen.GeneratedFile, f *fileInfo) {
}
g.P("ExtensionType: (", goType, ")(nil),")
g.P("Field: ", x.Desc.Number(), ",")
g.P("Name: ", strconv.Quote(string(name)), ",")
g.P("Name: ", strconv.Quote(string(x.Desc.FullName())), ",")
g.P("Tag: ", strconv.Quote(fieldProtobufTagValue(x.Extension)), ",")
g.P("Filename: ", strconv.Quote(f.Desc.Path()), ",")
g.P("},")
Expand Down
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/testprotos/conformance/test_messages_proto2.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/testprotos/messageset/msetextpb/msetextpb.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/testprotos/textpb2/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7c3f89

Please sign in to comment.