Skip to content

Commit

Permalink
reflect/protodesc: propagate field_presence legacy_required properly
Browse files Browse the repository at this point in the history
Change-Id: I3f067eb564349bc1ff867a03d9f1aa94b3428236
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/563735
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Stapelberg <[email protected]>
Auto-Submit: Lasse Folger <[email protected]>
  • Loading branch information
lfolger authored and gopherbot committed Feb 13, 2024
1 parent 020ec10 commit e391005
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
38 changes: 19 additions & 19 deletions cmd/protoc-gen-go/testdata/protoeditions/fields.pb.go

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

3 changes: 3 additions & 0 deletions reflect/protodesc/desc_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
if f.Base.L0.ParentFile.Syntax() == protoreflect.Editions {
f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures())

if f.L1.EditionFeatures.IsLegacyRequired {
f.L1.Cardinality = protoreflect.Required
}
// We reuse the existing field because the old option `[packed =
// true]` is mutually exclusive with the editions feature.
if canBePacked(fd) {
Expand Down

0 comments on commit e391005

Please sign in to comment.