From c5484a880320ab8f741e782ca9d77d2bf69cced6 Mon Sep 17 00:00:00 2001
From: Edward Brown <edward.brown@stfc.ac.uk>
Date: Wed, 21 Mar 2018 12:03:03 +0000
Subject: [PATCH] Re #221244: Changed other Property class operator= return
 types.

---
 Framework/API/inc/MantidAPI/WorkspaceProperty.h         | 3 +--
 Framework/API/inc/MantidAPI/WorkspaceProperty.tcc       | 5 +++--
 Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc | 6 +++---
 Framework/Kernel/test/ArrayPropertyTest.h               | 9 ++++++---
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Framework/API/inc/MantidAPI/WorkspaceProperty.h
index 75a5d27dfe5..fc9a66d00df 100644
--- a/Framework/API/inc/MantidAPI/WorkspaceProperty.h
+++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.h
@@ -95,8 +95,7 @@ public:
 
   WorkspaceProperty &operator=(const WorkspaceProperty &right);
 
-  boost::shared_ptr<TYPE> &
-  operator=(const boost::shared_ptr<TYPE> &value) override;
+  WorkspaceProperty &operator=(const boost::shared_ptr<TYPE> &value) override;
 
   WorkspaceProperty &operator+=(Kernel::Property const *) override;
 
diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc
index 1dbcb92a022..1894b6dded1 100644
--- a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc
+++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc
@@ -107,13 +107,14 @@ operator=(const WorkspaceProperty &right) {
  * @return assigned PropertyWithValue
  */
 template <typename TYPE>
-boost::shared_ptr<TYPE> &WorkspaceProperty<TYPE>::
+WorkspaceProperty<TYPE> &WorkspaceProperty<TYPE>::
 operator=(const boost::shared_ptr<TYPE> &value) {
   std::string wsName = value->getName();
   if (this->direction() == Kernel::Direction::Input && !wsName.empty()) {
     m_workspaceName = wsName;
   }
-  return Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value);
+  Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value);
+  return *this;
 }
 
 //--------------------------------------------------------------------------------------
diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc
index a4902017dbb..af580021274 100644
--- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc
+++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc
@@ -259,7 +259,7 @@ operator+=(Property const *right) {
  *  @return the reference to itself
  */
 template <typename TYPE>
-TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) {
+PropertyWithValue<TYPE> &PropertyWithValue<TYPE>::operator=(const TYPE &value) {
   TYPE oldValue = m_value;
   if (std::is_same<TYPE, std::string>::value) {
     std::string valueCopy = toString(value);
@@ -272,10 +272,10 @@ TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) {
   }
   std::string problem = this->isValid();
   if (problem.empty()) {
-    return m_value;
+    return *this;
   } else if (problem == "_alias") {
     m_value = getValueForAlias(value);
-    return m_value;
+    return *this;
   } else {
     m_value = oldValue;
     throw std::invalid_argument(problem);
diff --git a/Framework/Kernel/test/ArrayPropertyTest.h b/Framework/Kernel/test/ArrayPropertyTest.h
index 75408b0d46d..f15f1f2ab2e 100644
--- a/Framework/Kernel/test/ArrayPropertyTest.h
+++ b/Framework/Kernel/test/ArrayPropertyTest.h
@@ -242,21 +242,24 @@ public:
     ArrayProperty<int> i("i");
     TS_ASSERT(i.isDefault())
     std::vector<int> ii(3, 4);
-    TS_ASSERT_EQUALS(i = ii, ii)
+    i = ii;
+    TS_ASSERT_EQUALS(i.operator()(), ii);
     TS_ASSERT_EQUALS(i.operator()()[1], 4)
     TS_ASSERT(!i.isDefault())
 
     ArrayProperty<double> d("d");
     TS_ASSERT(d.isDefault())
     std::vector<double> dd(5, 9.99);
-    TS_ASSERT_EQUALS(d = dd, dd)
+    d = dd;
+    TS_ASSERT_EQUALS(d.operator()(), dd);
     TS_ASSERT_EQUALS(d.operator()()[3], 9.99)
     TS_ASSERT(!d.isDefault())
 
     ArrayProperty<std::string> s("s");
     TS_ASSERT(s.isDefault())
     std::vector<std::string> ss(2, "zzz");
-    TS_ASSERT_EQUALS(s = ss, ss)
+    s = ss;
+    TS_ASSERT_EQUALS(s.operator()(), ss)
     TS_ASSERT_EQUALS(s.operator()()[0], "zzz")
     TS_ASSERT(!s.isDefault())
   }
-- 
GitLab