@@ -60,22 +60,6 @@ class EmptyListValue final : public common_internal::CompatListValue {
6060
6161 size_t Size () const override { return 0 ; }
6262
63- absl::Status ConvertToJson (
64- absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
65- absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
66- absl::Nonnull<google::protobuf::Message*> json) const override {
67- ABSL_DCHECK (descriptor_pool != nullptr );
68- ABSL_DCHECK (message_factory != nullptr );
69- ABSL_DCHECK (json != nullptr );
70- ABSL_DCHECK_EQ (json->GetDescriptor ()->well_known_type (),
71- google::protobuf::Descriptor::WELLKNOWNTYPE_VALUE);
72-
73- ValueReflection value_reflection;
74- CEL_RETURN_IF_ERROR (value_reflection.Initialize (json->GetDescriptor ()));
75- value_reflection.MutableListValue (json)->Clear ();
76- return absl::OkStatus ();
77- }
78-
7963 absl::Status ConvertToJsonArray (
8064 absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
8165 absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
@@ -102,7 +86,6 @@ class EmptyListValue final : public common_internal::CompatListValue {
10286 return CelValue::CreateError (&*error);
10387 }
10488
105- using CompatListValue::Get;
10689 CelValue Get (google::protobuf::Arena* arena, int index) const override {
10790 if (arena == nullptr ) {
10891 return (*this )[index];
@@ -112,12 +95,12 @@ class EmptyListValue final : public common_internal::CompatListValue {
11295 }
11396
11497 private:
115- absl::Status GetImpl (size_t , absl::Nonnull<const google::protobuf::DescriptorPool*>,
116- absl::Nonnull<google::protobuf::MessageFactory*>,
117- absl::Nonnull<google::protobuf::Arena*>,
118- absl::Nonnull<Value*>) const override {
119- // Not reachable, `Get` performs index checking.
120- return absl::InternalError ( " unreachable " );
98+ absl::Status Get (size_t index , absl::Nonnull<const google::protobuf::DescriptorPool*>,
99+ absl::Nonnull<google::protobuf::MessageFactory*>,
100+ absl::Nonnull<google::protobuf::Arena*>,
101+ absl::Nonnull<Value*> result ) const override {
102+ *result = IndexOutOfBoundsError ( index);
103+ return absl::OkStatus ( );
121104 }
122105};
123106
@@ -149,8 +132,8 @@ class CustomListValueInterfaceIterator final : public ValueIterator {
149132 " ValueIterator::Next() called when "
150133 " ValueIterator::HasNext() returns false" );
151134 }
152- return interface_.GetImpl (index_++, descriptor_pool, message_factory, arena,
153- result);
135+ return interface_.Get (index_++, descriptor_pool, message_factory, arena,
136+ result);
154137 }
155138
156139 private:
@@ -221,17 +204,6 @@ absl::Status CustomListValueInterface::SerializeTo(
221204 return absl::OkStatus ();
222205}
223206
224- absl::Status CustomListValueInterface::Get (
225- size_t index, absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
226- absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
227- absl::Nonnull<google::protobuf::Arena*> arena, absl::Nonnull<Value*> result) const {
228- if (ABSL_PREDICT_FALSE (index >= Size ())) {
229- *result = IndexOutOfBoundsError (index);
230- return absl::OkStatus ();
231- }
232- return GetImpl (index, descriptor_pool, message_factory, arena, result);
233- }
234-
235207absl::Status CustomListValueInterface::ForEach (
236208 ForEachWithIndexCallback callback,
237209 absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
@@ -241,7 +213,7 @@ absl::Status CustomListValueInterface::ForEach(
241213 for (size_t index = 0 ; index < size; ++index) {
242214 Value element;
243215 CEL_RETURN_IF_ERROR (
244- GetImpl (index, descriptor_pool, message_factory, arena, &element));
216+ Get (index, descriptor_pool, message_factory, arena, &element));
245217 CEL_ASSIGN_OR_RETURN (auto ok, callback (index, element));
246218 if (!ok) {
247219 break ;
@@ -256,16 +228,12 @@ CustomListValueInterface::NewIterator() const {
256228}
257229
258230absl::Status CustomListValueInterface::Equal (
259- const Value & other,
231+ const ListValue & other,
260232 absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
261233 absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
262234 absl::Nonnull<google::protobuf::Arena*> arena, absl::Nonnull<Value*> result) const {
263- if (auto list_value = other.As <ListValue>(); list_value.has_value ()) {
264- return ListValueEqual (*this , *list_value, descriptor_pool, message_factory,
265- arena, result);
266- }
267- *result = FalseValue ();
268- return absl::OkStatus ();
235+ return ListValueEqual (*this , other, descriptor_pool, message_factory, arena,
236+ result);
269237}
270238
271239absl::Status CustomListValueInterface::Contains (
@@ -301,7 +269,7 @@ NativeTypeId CustomListValue::GetTypeId() const {
301269 CustomListValueInterface::Content content =
302270 content_.To <CustomListValueInterface::Content>();
303271 ABSL_DCHECK (content.interface != nullptr );
304- return NativeTypeId::Of (* content.interface );
272+ return content.interface -> GetNativeTypeId ( );
305273 }
306274 return dispatcher_->get_type_id (dispatcher_, content_);
307275}
@@ -392,14 +360,14 @@ absl::Status CustomListValue::Equal(
392360 ABSL_DCHECK (arena != nullptr );
393361 ABSL_DCHECK (result != nullptr );
394362
395- if (dispatcher_ == nullptr ) {
396- CustomListValueInterface::Content content =
397- content_.To <CustomListValueInterface::Content>();
398- ABSL_DCHECK (content.interface != nullptr );
399- return content.interface ->Equal (other, descriptor_pool, message_factory,
400- arena, result);
401- }
402363 if (auto other_list_value = other.AsList (); other_list_value) {
364+ if (dispatcher_ == nullptr ) {
365+ CustomListValueInterface::Content content =
366+ content_.To <CustomListValueInterface::Content>();
367+ ABSL_DCHECK (content.interface != nullptr );
368+ return content.interface ->Equal (*other_list_value, descriptor_pool,
369+ message_factory, arena, result);
370+ }
403371 if (dispatcher_->equal != nullptr ) {
404372 return dispatcher_->equal (dispatcher_, content_, *other_list_value,
405373 descriptor_pool, message_factory, arena,
0 commit comments