diff src/ov-fcn-handle.cc @ 13193:a00ff5cedb9b

also look to parent classes for overloaded functions called through handles * ov-fcn-handle.cc (octave_fcn_handle::do_multi_index_op): Look for overloads in parent classes if none are found in the immediate dispatch class. * test/fcn-handle-derived-resolution: New directory for tests. * test/Makefile.am: Include fcn-handle-derived-resolution/module.mk.
author John W. Eaton <jwe@octave.org>
date Thu, 22 Sep 2011 17:08:49 -0400
parents 65b7ce254ba3
children d6118a2c0644
line wrap: on
line diff
--- a/src/ov-fcn-handle.cc	Thu Sep 22 16:44:54 2011 -0400
+++ b/src/ov-fcn-handle.cc	Thu Sep 22 17:08:49 2011 -0400
@@ -164,7 +164,38 @@
       else
         {
           str_ov_map::iterator it = overloads.find (dispatch_type);
-          if (it != overloads.end ())
+
+          if (it == overloads.end ())
+            {
+              // Try parent classes too.
+
+              std::list<std::string> plist
+                = symbol_table::parent_classes (dispatch_type);
+
+              std::list<std::string>::const_iterator pit = plist.begin ();
+
+              while (pit != plist.end ())
+                {
+                  std::string pname = *pit;
+
+                  std::string fnm = fcn_name ();
+
+                  octave_value ftmp = symbol_table::find_method (fnm, pname);
+
+                  if (ftmp.is_defined ())
+                    {
+                      set_overload (pname, ftmp);
+
+                      out_of_date_check (ftmp, pname, false);
+                      ov_fcn = ftmp;
+
+                      break;
+                    }
+
+                  pit++;
+                }
+            }
+          else
             {
               out_of_date_check (it->second, dispatch_type, false);
               ov_fcn = it->second;