From eea33cd93e02b0b4a5c3fddffa13ff4ddecc9182 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 27 Jun 2024 10:47:35 -0700 Subject: [PATCH] protobuf: fix handling of delimited extensions in editions Change-Id: I5207e3e1d51e55147a7ec8374548aeb6a5312172 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/595337 Reviewed-by: Lasse Folger Reviewed-by: Michael Stapelberg Auto-Submit: Michael Stapelberg LUCI-TryBot-Result: Go LUCI --- .../conformance/editions/test_messages_edition2023.pb.go | 4 ++-- .../editionsmigration/test_messages_proto2_editions.pb.go | 2 +- internal/testprotos/testeditions/test_extension.pb.go | 4 ++-- reflect/protodesc/desc_init.go | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/testprotos/conformance/editions/test_messages_edition2023.pb.go b/internal/testprotos/conformance/editions/test_messages_edition2023.pb.go index c15a00062..6ccaa4108 100644 --- a/internal/testprotos/conformance/editions/test_messages_edition2023.pb.go +++ b/internal/testprotos/conformance/editions/test_messages_edition2023.pb.go @@ -1251,7 +1251,7 @@ var file_conformance_test_protos_test_messages_edition2023_proto_extTypes = []pr ExtensionType: (*GroupLikeType)(nil), Field: 121, Name: "protobuf_test_messages.editions.groupliketype", - Tag: "bytes,121,opt,name=groupliketype", + Tag: "group,121,opt,name=GroupLikeType", Filename: "conformance/test_protos/test_messages_edition2023.proto", }, { @@ -1259,7 +1259,7 @@ var file_conformance_test_protos_test_messages_edition2023_proto_extTypes = []pr ExtensionType: (*GroupLikeType)(nil), Field: 122, Name: "protobuf_test_messages.editions.delimited_ext", - Tag: "bytes,122,opt,name=delimited_ext", + Tag: "group,122,opt,name=GroupLikeType", Filename: "conformance/test_protos/test_messages_edition2023.proto", }, } diff --git a/internal/testprotos/conformance/editionsmigration/test_messages_proto2_editions.pb.go b/internal/testprotos/conformance/editionsmigration/test_messages_proto2_editions.pb.go index e14ad7b35..bf2f28e0e 100644 --- a/internal/testprotos/conformance/editionsmigration/test_messages_proto2_editions.pb.go +++ b/internal/testprotos/conformance/editionsmigration/test_messages_proto2_editions.pb.go @@ -2806,7 +2806,7 @@ var file_editions_golden_test_messages_proto2_editions_proto_extTypes = []protoi ExtensionType: (*GroupField)(nil), Field: 121, Name: "protobuf_test_messages.editions.proto2.groupfield", - Tag: "bytes,121,opt,name=groupfield", + Tag: "group,121,opt,name=GroupField", Filename: "editions/golden/test_messages_proto2_editions.proto", }, { diff --git a/internal/testprotos/testeditions/test_extension.pb.go b/internal/testprotos/testeditions/test_extension.pb.go index 2d7cb1458..5adc5d4e6 100644 --- a/internal/testprotos/testeditions/test_extension.pb.go +++ b/internal/testprotos/testeditions/test_extension.pb.go @@ -429,7 +429,7 @@ var file_internal_testprotos_testeditions_test_extension_proto_extTypes = []prot ExtensionType: (*OptionalGroup)(nil), Field: 16, Name: "goproto.proto.testeditions.optionalgroup", - Tag: "bytes,16,opt,name=optionalgroup", + Tag: "group,16,opt,name=OptionalGroup", Filename: "internal/testprotos/testeditions/test_extension.proto", }, { @@ -573,7 +573,7 @@ var file_internal_testprotos_testeditions_test_extension_proto_extTypes = []prot ExtensionType: ([]*RepeatedGroup)(nil), Field: 46, Name: "goproto.proto.testeditions.repeatedgroup", - Tag: "bytes,46,rep,name=repeatedgroup", + Tag: "group,46,rep,name=RepeatedGroup", Filename: "internal/testprotos/testeditions/test_extension.proto", }, { diff --git a/reflect/protodesc/desc_init.go b/reflect/protodesc/desc_init.go index 856175542..42c1f83db 100644 --- a/reflect/protodesc/desc_init.go +++ b/reflect/protodesc/desc_init.go @@ -214,6 +214,9 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript if xd.JsonName != nil { x.L2.StringName.InitJSON(xd.GetJsonName()) } + if x.L1.Kind == protoreflect.MessageKind && x.L1.EditionFeatures.IsDelimitedEncoded { + x.L1.Kind = protoreflect.GroupKind + } } return xs, nil }