changeset 28482:98fbb75cd028

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Mon, 15 Jun 2020 16:46:51 -0400
parents 888e79a46a85 (current diff) 1be719d8b375 (diff)
children 6dd150e3c785
files
diffstat 7 files changed, 53 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-fcn-handle.cc	Mon Jun 15 13:36:27 2020 -0700
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Mon Jun 15 16:46:51 2020 -0400
@@ -397,15 +397,18 @@
     // FIXME: octaveroot is temporary information used when loading
     // handles.  Can we avoid using it in the constructor?
 
-    class_simple_fcn_handle (const std::string& name = "",
-                             const std::string& file = "",
-                             const std::string& /*octaveroot*/ = "")
+    class_simple_fcn_handle (const std::string& name,
+                             const std::string& file,
+                             const std::string& /*octaveroot*/)
       : base_fcn_handle (name, file)
     { }
 
     // FIXME: is the method name supposed to be just the method name or
     // also contain the object name?
 
+    class_simple_fcn_handle (const std::string& class_nm,
+                             const std::string& meth_nm);
+
     class_simple_fcn_handle (const octave_value& fcn,
                              const std::string& class_nm,
                              const std::string& meth_nm);
@@ -1586,6 +1589,12 @@
       return false;
   }
 
+  class_simple_fcn_handle::class_simple_fcn_handle (const std::string& class_nm,
+                                                    const std::string& meth_nm)
+    : base_fcn_handle (meth_nm), m_obj (), m_fcn (),
+      m_dispatch_class (class_nm)
+  { }
+
   class_simple_fcn_handle::class_simple_fcn_handle (const octave_value& fcn,
                                                     const std::string& class_nm,
                                                     const std::string& meth_nm)
@@ -1625,7 +1634,10 @@
 
     tw.set_dispatch_class (m_dispatch_class);
 
-    return interp.feval (m_fcn, args, nargout);
+    if (m_fcn.is_defined ())
+      return interp.feval (m_fcn, args, nargout);
+
+    return interp.feval (fcn_name (), args, nargout);
   }
 
   octave_scalar_map class_simple_fcn_handle::info (void)
@@ -2448,6 +2460,12 @@
   : octave_base_value (), m_rep (new octave::simple_fcn_handle (fcn, name))
 { }
 
+octave_fcn_handle::octave_fcn_handle (const std::string& class_nm,
+                                      const std::string& meth_nm)
+  : octave_base_value (),
+    m_rep (new octave::class_simple_fcn_handle (class_nm, meth_nm))
+{ }
+
 octave_fcn_handle::octave_fcn_handle (const octave_value& fcn,
                                       const std::string& class_nm,
                                       const std::string& meth_nm)
--- a/libinterp/octave-value/ov-fcn-handle.h	Mon Jun 15 13:36:27 2020 -0700
+++ b/libinterp/octave-value/ov-fcn-handle.h	Mon Jun 15 16:46:51 2020 -0400
@@ -179,6 +179,9 @@
   // Create a simple function handle that is bound to a function.
   octave_fcn_handle (const octave_value& fcn, const std::string& name);
 
+  // Create a function handle that might be bound to a class method.
+  octave_fcn_handle (const std::string& class_nm, const std::string& meth_nm);
+
   // Create a function handle bound to a class method.
   octave_fcn_handle (const octave_value& fcn, const std::string& class_nm,
                      const std::string& meth_nm);
--- a/libinterp/parse-tree/pt-eval.cc	Mon Jun 15 13:36:27 2020 -0700
+++ b/libinterp/parse-tree/pt-eval.cc	Mon Jun 15 16:46:51 2020 -0400
@@ -1186,11 +1186,11 @@
 
                 if (fcn->is_class_method ())
                   {
-                    // Create CLASSSIMPLE handle to method.
+                    // Create CLASSSIMPLE handle to method but don't
+                    // bind to the method.  Lookup will be done later.
 
                     octave_fcn_handle *fh
-                      = new octave_fcn_handle (ov_meth, dispatch_class,
-                                               fcn_name);
+                      = new octave_fcn_handle (dispatch_class, fcn_name);
 
                     return octave_value (fh);
                   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-58572/bug-58572.tst	Mon Jun 15 16:46:51 2020 -0400
@@ -0,0 +1,6 @@
+%!test
+%! obj = bug58572 ();
+%! assert (use_num (obj), false);
+%! assert (obj.use_num (), false);
+%! assert (isnumeric (obj), true);
+%! assert (obj.isnumeric (), true);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-58572/bug58572.m	Mon Jun 15 16:46:51 2020 -0400
@@ -0,0 +1,13 @@
+classdef bug58572
+  methods
+    function rslt = use_num (obj)
+      rslt = cellfun (@isnumeric, {'a_name'});
+    endfunction
+    function rslt = isnumeric (obj)
+      if (! isa (obj, 'bug58572'))
+        error ('bug58572.isnumeric called without object!');
+      endif
+      rslt = true;
+    endfunction
+  endmethods
+endclassdef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-58572/module.mk	Mon Jun 15 16:46:51 2020 -0400
@@ -0,0 +1,5 @@
+bug_58572_TEST_FILES = \
+  %reldir%/bug-58572.tst \
+  %reldir%/bug58572.m
+
+TEST_FILES += $(bug_58572_TEST_FILES)
--- a/test/module.mk	Mon Jun 15 13:36:27 2020 -0700
+++ b/test/module.mk	Mon Jun 15 16:46:51 2020 -0400
@@ -82,6 +82,7 @@
 include %reldir%/bug-53956/module.mk
 include %reldir%/bug-54995/module.mk
 include %reldir%/bug-55758/module.mk
+include %reldir%/bug-58572/module.mk
 include %reldir%/class-concat/module.mk
 include %reldir%/classdef/module.mk
 include %reldir%/classdef-multiple-inheritance/module.mk