From 0a6a51655f3f6af554766d88b6d717e31af34b01 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Tue, 5 Dec 2023 10:08:33 -0800 Subject: [PATCH] Breaking change: Remove deprecated SupportsUnknownEnumValues method PiperOrigin-RevId: 588109737 --- .../protobuf/generated_message_reflection.cc | 5 --- src/google/protobuf/message.h | 33 ------------------- 2 files changed, 38 deletions(-) diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc index c75c29004c..b5ffcab1df 100644 --- a/src/google/protobuf/generated_message_reflection.cc +++ b/src/google/protobuf/generated_message_reflection.cc @@ -2655,11 +2655,6 @@ const FieldDescriptor* Reflection::FindKnownExtensionByNumber( return descriptor_pool_->FindExtensionByNumber(descriptor_, number); } -bool Reflection::SupportsUnknownEnumValues() const { - return FileDescriptorLegacy(descriptor_->file()).syntax() == - FileDescriptorLegacy::Syntax::SYNTAX_PROTO3; -} - // =================================================================== // Some private helpers. diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h index add5977ce0..d25c2d7815 100644 --- a/src/google/protobuf/message.h +++ b/src/google/protobuf/message.h @@ -887,39 +887,6 @@ class PROTOBUF_EXPORT Reflection final { // Returns nullptr if no extension is known for this name or number. const FieldDescriptor* FindKnownExtensionByNumber(int number) const; - // Feature Flags ------------------------------------------------------------- - - // Does this message support storing arbitrary integer values in enum fields? - // If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions - // take arbitrary integer values, and the legacy GetEnum() getter will - // dynamically create an EnumValueDescriptor for any integer value without - // one. If |false|, setting an unknown enum value via the integer-based - // setters results in undefined behavior (in practice, ABSL_DCHECK-fails). - // - // Generic code that uses reflection to handle messages with enum fields - // should check this flag before using the integer-based setter, and either - // downgrade to a compatible value or use the UnknownFieldSet if not. For - // example: - // - // int new_value = GetValueFromApplicationLogic(); - // if (reflection->SupportsUnknownEnumValues()) { - // reflection->SetEnumValue(message, field, new_value); - // } else { - // if (field_descriptor->enum_type()-> - // FindValueByNumber(new_value) != nullptr) { - // reflection->SetEnumValue(message, field, new_value); - // } else if (emit_unknown_enum_values) { - // reflection->MutableUnknownFields(message)->AddVarint( - // field->number(), new_value); - // } else { - // // convert value to a compatible/default value. - // new_value = CompatibleDowngrade(new_value); - // reflection->SetEnumValue(message, field, new_value); - // } - // } - ABSL_DEPRECATED("Use EnumDescriptor::is_closed instead.") - bool SupportsUnknownEnumValues() const; - // Returns the MessageFactory associated with this message. This can be // useful for determining if a message is a generated message or not, for // example: