Skip to content

Commit 7407bce

Browse files
authored
Track some more upstream changes moving off label. (#1769)
This just keeps the Swift versions inline with the upstream protobuf code.
1 parent 30092b0 commit 7407bce

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/SwiftProtobufPluginLibrary/Descriptor.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,15 @@ public final class FieldDescriptor {
10921092
/// This should never be called directly. Use isRequired and isRepeated
10931093
/// helper methods instead.
10941094
@available(*, deprecated, message: "Use isRequired or isRepeated instead.")
1095-
public var label: Google_Protobuf_FieldDescriptorProto.Label { _label }
1095+
public var label: Google_Protobuf_FieldDescriptorProto.Label {
1096+
if isRepeated {
1097+
return .repeated
1098+
} else if isRequired {
1099+
return .required
1100+
} else {
1101+
return .optional
1102+
}
1103+
}
10961104

10971105
// Storage for `label`, used by other apis.
10981106
private var _label: Google_Protobuf_FieldDescriptorProto.Label
@@ -1132,7 +1140,7 @@ public final class FieldDescriptor {
11321140
var _hasOptionalKeyword: Bool {
11331141
// This logic comes from the C++ FieldDescriptor::has_optional_keyword()
11341142
// impl.
1135-
proto3Optional || (file.edition == .proto2 && _label == .optional && oneofIndex == nil)
1143+
proto3Optional || (file.edition == .proto2 && !isRequired && !isRepeated && oneofIndex == nil)
11361144
}
11371145
@available(*, deprecated, message: "Please open a GitHub issue if you think functionality is missing.")
11381146
public var hasOptionalKeyword: Bool {

0 commit comments

Comments
 (0)