Internal changes

PiperOrigin-RevId: 537988020
pull/12985/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 010fde9a18
commit a10c2b77c3
  1. 12
      src/google/protobuf/descriptor.cc

@ -3599,8 +3599,10 @@ bool FieldDescriptor::has_presence() const {
}
bool FieldDescriptor::legacy_enum_field_treated_as_closed() const {
return type() == TYPE_ENUM && FileDescriptorLegacy(file_).syntax() ==
FileDescriptorLegacy::Syntax::SYNTAX_PROTO2;
return type() == TYPE_ENUM &&
(FileDescriptorLegacy(file_).syntax() ==
FileDescriptorLegacy::Syntax::SYNTAX_PROTO2 ||
enum_type()->is_closed());
}
// Location methods ===============================================
@ -8873,7 +8875,11 @@ void LazyDescriptor::Once(const ServiceDescriptor* service) {
namespace cpp {
bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) {
return !field->legacy_enum_field_treated_as_closed();
if (field->legacy_enum_field_treated_as_closed()) {
return false;
}
return field->enum_type() != nullptr && !field->enum_type()->is_closed();
}
bool HasHasbit(const FieldDescriptor* field) {

Loading…
Cancel
Save