File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
SwiftProtobufPluginLibrary Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -1092,18 +1092,19 @@ public final class FieldDescriptor {
10921092 /// optional/required/repeated
10931093 public let label : Google_Protobuf_FieldDescriptorProto . Label
10941094
1095- /// Shorthand for `label` == `.required`.
1096- ///
1097- /// NOTE: This could also be a map as the are also repeated fields.
1095+ /// Whether or not the field is required. For proto2 required fields and
1096+ /// Editions `LEGACY_REQUIRED` fields.
10981097 public var isRequired : Bool {
10991098 // Implementation comes from FieldDescriptor::is_required()
11001099 features. fieldPresence == . legacyRequired
11011100 }
1102- /// Shorthand for `label` == `.optional`
1103- public var isOptional : Bool { label == . optional }
1104- /// Shorthand for `label` == `.repeated`
1101+ /// Whether or not the field is repeated/map field.
11051102 public var isRepeated : Bool { label == . repeated }
11061103
1104+ /// Use !isRequired() && !isRepeated() instead.
1105+ @available ( * , deprecated, message: " Use !isRequired() && !isRepeated() instead. " )
1106+ public var isOptional : Bool { label == . optional }
1107+
11071108 /// Is this field packable.
11081109 public var isPackable : Bool {
11091110 // This logic comes from the C++ FieldDescriptor::is_packable() impl.
Original file line number Diff line number Diff line change @@ -117,9 +117,9 @@ class MessageGenerator {
117117 " \( e. containingType. fullName) has the option message_set_wire_format but \( e. fullName) is a non message extension field. "
118118 return
119119 }
120- guard e . isOptional else {
120+ guard !e . isRequired && !e . isRepeated else {
121121 errorString =
122- " \( e. containingType. fullName) has the option message_set_wire_format but \( e. fullName) is not a \" optional \" extension field. "
122+ " \( e. containingType. fullName) has the option message_set_wire_format but \( e. fullName) cannot be required nor repeated extension field. "
123123 return
124124 }
125125 }
You can’t perform that action at this time.
0 commit comments