Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/legacy_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions common/values/type_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class TypeValue final : private common_internal::ValueMixin<TypeValue> {
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;
Expand Down Expand Up @@ -82,16 +81,24 @@ class TypeValue final : private common_internal::ValueMixin<TypeValue> {

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<TypeValue>;
Expand All @@ -100,8 +107,6 @@ class TypeValue final : private common_internal::ValueMixin<TypeValue> {
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();
}
Expand Down