From 3ea464b72562425ca7d15da75543554f8cd62f71 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 31 Mar 2021 12:47:49 -0700 Subject: [PATCH] Make EncodableValue::LongValue const (#25335) This method doesn't mutate the value of the underlying variant. Fixes https://github.com/flutter/flutter/issues/79472 --- .../common/client_wrapper/encodable_value_unittests.cc | 8 ++++---- .../client_wrapper/include/flutter/encodable_value.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/platform/common/client_wrapper/encodable_value_unittests.cc b/shell/platform/common/client_wrapper/encodable_value_unittests.cc index 9a02cde08..3fcf83aa2 100644 --- a/shell/platform/common/client_wrapper/encodable_value_unittests.cc +++ b/shell/platform/common/client_wrapper/encodable_value_unittests.cc @@ -33,10 +33,10 @@ TEST(EncodableValueTest, Int) { // Test the int/long convenience wrapper. TEST(EncodableValueTest, LongValue) { - EncodableValue value(std::numeric_limits::max()); - EXPECT_EQ(value.LongValue(), std::numeric_limits::max()); - value = std::numeric_limits::max(); - EXPECT_EQ(value.LongValue(), std::numeric_limits::max()); + const EncodableValue int_value(std::numeric_limits::max()); + EXPECT_EQ(int_value.LongValue(), std::numeric_limits::max()); + const EncodableValue long_value(std::numeric_limits::max()); + EXPECT_EQ(long_value.LongValue(), std::numeric_limits::max()); } TEST(EncodableValueTest, Long) { diff --git a/shell/platform/common/client_wrapper/include/flutter/encodable_value.h b/shell/platform/common/client_wrapper/include/flutter/encodable_value.h index 1fbbe7e55..30f4f7a56 100644 --- a/shell/platform/common/client_wrapper/include/flutter/encodable_value.h +++ b/shell/platform/common/client_wrapper/include/flutter/encodable_value.h @@ -203,7 +203,7 @@ class EncodableValue : public internal::EncodableValueVariant { // // Calling this method if the value doesn't contain either an int32_t or an // int64_t will throw an exception. - int64_t LongValue() { + int64_t LongValue() const { if (std::holds_alternative(*this)) { return std::get(*this); } -- GitLab