File tree 2 files changed +9
-8
lines changed
SwiftProtobufPluginLibrary
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 {
1092
1092
/// optional/required/repeated
1093
1093
public let label : Google_Protobuf_FieldDescriptorProto . Label
1094
1094
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.
1098
1097
public var isRequired : Bool {
1099
1098
// Implementation comes from FieldDescriptor::is_required()
1100
1099
features. fieldPresence == . legacyRequired
1101
1100
}
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.
1105
1102
public var isRepeated : Bool { label == . repeated }
1106
1103
1104
+ /// Use !isRequired() && !isRepeated() instead.
1105
+ @available ( * , deprecated, message: " Use !isRequired() && !isRepeated() instead. " )
1106
+ public var isOptional : Bool { label == . optional }
1107
+
1107
1108
/// Is this field packable.
1108
1109
public var isPackable : Bool {
1109
1110
// 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 {
117
117
" \( e. containingType. fullName) has the option message_set_wire_format but \( e. fullName) is a non message extension field. "
118
118
return
119
119
}
120
- guard e . isOptional else {
120
+ guard !e . isRequired && !e . isRepeated else {
121
121
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. "
123
123
return
124
124
}
125
125
}
You can’t perform that action at this time.
0 commit comments