diff --git a/common/legacy_value.cc b/common/legacy_value.cc index 05217ac7d..a2f6744ec 100644 --- a/common/legacy_value.cc +++ b/common/legacy_value.cc @@ -987,7 +987,7 @@ absl::Status ModernValue(google::protobuf::Arena* arena, if (type_name.empty()) { return absl::InvalidArgumentError("empty type name in CelValue"); } - result = TypeValue{common_internal::LegacyRuntimeType(type_name)}; + result = TypeValue(common_internal::LegacyRuntimeType(type_name)); return absl::OkStatus(); } case CelValue::Type::kError: @@ -1188,7 +1188,7 @@ google::api::expr::runtime::CelValue ModernValueToLegacyValueOrDie( TypeValue CreateTypeValueFromView(google::protobuf::Arena* arena, absl::string_view input) { - return common_internal::LegacyRuntimeType(input); + return TypeValue(common_internal::LegacyRuntimeType(input)); } } // namespace interop_internal diff --git a/common/values/type_value.h b/common/values/type_value.h index 885834deb..779204e00 100644 --- a/common/values/type_value.h +++ b/common/values/type_value.h @@ -46,8 +46,7 @@ class TypeValue final : private common_internal::ValueMixin { public: static constexpr ValueKind kKind = ValueKind::kType; - // NOLINTNEXTLINE(google-explicit-constructor) - TypeValue(Type value) noexcept : value_(std::move(value)) {} + explicit TypeValue(Type value) : value_(std::move(value)) {} TypeValue() = default; TypeValue(const TypeValue&) = default; @@ -82,16 +81,24 @@ class TypeValue final : private common_internal::ValueMixin { bool IsZeroValue() const { return false; } + ABSL_DEPRECATED(("Use type()")) const Type& NativeValue() const ABSL_ATTRIBUTE_LIFETIME_BOUND { return value_; } + const Type& type() const ABSL_ATTRIBUTE_LIFETIME_BOUND { return value_; } + void swap(TypeValue& other) noexcept { using std::swap; swap(value_, other.value_); } - absl::string_view name() const { return NativeValue().name(); } + absl::string_view name() const { return type().name(); } + + friend void swap(TypeValue& lhs, TypeValue& rhs) noexcept { + using std::swap; + swap(lhs.value_, rhs.value_); + } private: friend struct NativeTypeTraits; @@ -100,8 +107,6 @@ class TypeValue final : private common_internal::ValueMixin { Type value_; }; -inline void swap(TypeValue& lhs, TypeValue& rhs) noexcept { lhs.swap(rhs); } - inline std::ostream& operator<<(std::ostream& out, const TypeValue& value) { return out << value.DebugString(); }