From 2e63fc4bc075a48d3f5c4e177acd6d7c71a43b39 Mon Sep 17 00:00:00 2001 From: Josh Humphries <2035234+jhump@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:20:48 -0400 Subject: [PATCH] add comment per review suggestion; add another in the same vein, for clarity --- linker/descriptors.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linker/descriptors.go b/linker/descriptors.go index 4548e661..b15d5715 100644 --- a/linker/descriptors.go +++ b/linker/descriptors.go @@ -1048,6 +1048,8 @@ func (f *fldDescriptor) Cardinality() protoreflect.Cardinality { return protoreflect.Required case descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL: if f.Syntax() == protoreflect.Editions { + // Editions does not use label to indicate required. It instead + // uses a feature, and label is always optional. fieldPresence := descriptorpb.FeatureSet_FieldPresence(resolveFeature(f, fieldPresenceField).Enum()) if fieldPresence == descriptorpb.FeatureSet_LEGACY_REQUIRED { return protoreflect.Required @@ -1061,6 +1063,8 @@ func (f *fldDescriptor) Cardinality() protoreflect.Cardinality { func (f *fldDescriptor) Kind() protoreflect.Kind { if f.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE && f.Syntax() == protoreflect.Editions { + // In editions, "group encoding" (aka "delimited encoding") is toggled + // via a feature. So we report group kind when that feature is enabled. messageEncoding := resolveFeature(f, messageEncodingField) if descriptorpb.FeatureSet_MessageEncoding(messageEncoding.Enum()) == descriptorpb.FeatureSet_DELIMITED { return protoreflect.GroupKind