Joshua Haberman 5 years ago
parent 3c3646fa78
commit c0b1ce00f3
  1. 2
      src/google/protobuf/generated_message_reflection.cc
  2. 6
      src/google/protobuf/proto3_arena_unittest.cc
  3. 4
      src/google/protobuf/unittest_proto3_optional.proto

@ -1061,7 +1061,7 @@ void Reflection::ListFields(const Message& message,
if (oneof_case_array[containing_oneof->index()] == field->number()) {
output->push_back(field);
}
} else if (has_bits) {
} else if (has_bits && has_bits_indices[i] != -1) {
// Equivalent to: HasBit(message, field)
if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) {
output->push_back(field);

@ -217,10 +217,16 @@ TEST(Proto3OptionalTest, OptionalFieldDescriptor) {
for (int i = 0; i < d->field_count(); i++) {
const FieldDescriptor* f = d->field(i);
if (HasPrefixString(f->name(), "singular")) {
EXPECT_FALSE(f->has_optional_keyword()) << f->full_name();
EXPECT_FALSE(f->has_presence()) << f->full_name();
EXPECT_FALSE(f->containing_oneof()) << f->full_name();
} else {
EXPECT_TRUE(f->has_optional_keyword()) << f->full_name();
EXPECT_TRUE(f->has_presence()) << f->full_name();
EXPECT_TRUE(f->containing_oneof()) << f->full_name();
}
}
}
TEST(Proto3OptionalTest, OptionalField) {

@ -72,4 +72,8 @@ message TestProto3Optional {
optional NestedMessage optional_nested_message = 18;
optional NestedMessage lazy_nested_message = 19 [lazy = true];
optional NestedEnum optional_nested_enum = 21;
// Add some non-optional fields to verify we can mix them.
int32 singular_int32 = 22;
int64 singular_int64 = 23;
}

Loading…
Cancel
Save