Skip to content

Commit

Permalink
Switch from static_cast to member functions for conversion
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676953959
  • Loading branch information
jcking authored and copybara-github committed Sep 23, 2024
1 parent 1040e41 commit 7f8b769
Show file tree
Hide file tree
Showing 40 changed files with 911 additions and 383 deletions.
6 changes: 3 additions & 3 deletions common/legacy_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class CelListValueBuilder final : public ListValueBuilder {

absl::Status Add(Value value) override {
if (value.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(value)).NativeValue();
return std::move(value).Get<ErrorValue>().NativeValue();
}
CEL_ASSIGN_OR_RETURN(auto legacy_value, LegacyValue(arena_, value));
elements_.push_back(legacy_value);
Expand Down Expand Up @@ -501,10 +501,10 @@ class CelMapValueBuilder final : public MapValueBuilder {

absl::Status Put(Value key, Value value) override {
if (key.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(key)).NativeValue();
return std::move(key).Get<ErrorValue>().NativeValue();
}
if (value.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(value)).NativeValue();
return std::move(value).Get<ErrorValue>().NativeValue();
}
CEL_ASSIGN_OR_RETURN(auto legacy_key, LegacyValue(arena_, key));
CEL_ASSIGN_OR_RETURN(auto legacy_value, LegacyValue(arena_, value));
Expand Down
2 changes: 1 addition & 1 deletion common/list_type_reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ListValueBuilderImpl final : public ListValueBuilder {

absl::Status Add(Value value) override {
if (value.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(value)).NativeValue();
return std::move(value).Get<ErrorValue>().NativeValue();
}
elements_.push_back(std::move(value));
return absl::OkStatus();
Expand Down
4 changes: 2 additions & 2 deletions common/map_type_reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ class MapValueBuilderImpl final : public MapValueBuilder {

absl::Status Put(Value key, Value value) override {
if (key.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(key)).NativeValue();
return std::move(key).Get<ErrorValue>().NativeValue();
}
if (value.Is<ErrorValue>()) {
return static_cast<ErrorValue>(std::move(value)).NativeValue();
return std::move(value).Get<ErrorValue>().NativeValue();
}
auto inserted = entries_.insert({std::move(key), std::move(value)}).second;
if (!inserted) {
Expand Down
Loading

0 comments on commit 7f8b769

Please # to comment.