Skip to content

Track some more upstream changes moving off label. #1769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Sources/SwiftProtobufPluginLibrary/Descriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,15 @@ public final class FieldDescriptor {
/// This should never be called directly. Use isRequired and isRepeated
/// helper methods instead.
@available(*, deprecated, message: "Use isRequired or isRepeated instead.")
public var label: Google_Protobuf_FieldDescriptorProto.Label { _label }
public var label: Google_Protobuf_FieldDescriptorProto.Label {
if isRepeated {
return .repeated
} else if isRequired {
return .required
} else {
return .optional
}
}

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