Skip to content

Commit

Permalink
Use feature helpers for resolved feature validation.
Browse files Browse the repository at this point in the history
There is a subtle behavior difference here when AllowUnknownDependencies is set on the pool, since unknown feature values are theoretically possible there.

PiperOrigin-RevId: 713301571
  • Loading branch information
mkruskal-google authored and copybara-github committed Jan 8, 2025
1 parent 4d0ba00 commit 46ba82b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/google/protobuf/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8168,14 +8168,12 @@ void DescriptorBuilder::ValidateFieldFeatures(
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
"Implicit presence fields can't specify defaults.");
}
if (field->enum_type() != nullptr &&
field->enum_type()->features().enum_type() != FeatureSet::OPEN) {
if (field->enum_type() != nullptr && field->enum_type()->is_closed()) {
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
"Implicit presence enum fields must always be open.");
}
}
if (field->is_extension() &&
field->features().field_presence() == FeatureSet::LEGACY_REQUIRED) {
if (field->is_extension() && field->is_required()) {
AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::NAME,
"Extensions can't be required.");
}
Expand Down

0 comments on commit 46ba82b

Please sign in to comment.