Skip to content

Commit c9bf607

Browse files
committed
Update FieldDescriptor isPacked to not check hasOptions.
1 parent 818d6af commit c9bf607

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/SwiftProtobufPluginLibrary/Descriptor.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,14 @@ public final class FieldDescriptor {
683683
// This logic comes from the C++ FieldDescriptor::is_packed() impl.
684684
// NOTE: It does not match what is in the C++ header for is_packed().
685685
guard isPackable else { return false }
686+
// The C++ imp also checks if the `options_` are null, but that is only for
687+
// their placeholder descriptor support, as once the FieldDescriptor is
688+
// fully wired it gets a default FileOptions instance, rendering nullptr
689+
// meaningless.
686690
if file.syntax == .proto2 {
687-
return proto.hasOptions && proto.options.packed
691+
return options.packed
688692
} else {
689-
return !proto.hasOptions || !proto.options.hasPacked || proto.options.packed
693+
return !options.hasPacked || options.packed
690694
}
691695
}
692696
/// True if this field is a map.

0 commit comments

Comments
 (0)