diff --git a/libinterp/octave-value/ov-fcn-handle.cc b/libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc +++ b/libinterp/octave-value/ov-fcn-handle.cc @@ -736,14 +736,21 @@ namespace octave octave_value_list simple_fcn_handle::call (int nargout, const octave_value_list& args) { + interpreter& interp = __get_interpreter__ ("simple_fcn_handle::call"); + + // If the function was visible at the point of handle creation, + // m_fcn should be defined and we will use it. Otherwise, we will + // always perform the search here, at the point of the call. + + if (m_fcn.is_defined ()) + return interp.feval (m_fcn, args, nargout); + + octave_value fcn_to_call; + // FIXME: if m_name has a '.' in the name, lookup first component. If // it is a classdef meta object, then build TYPE and IDX arguments and // make a subsref call using them. - interpreter& interp = __get_interpreter__ ("simple_fcn_handle::call"); - - octave_value fcn_to_call; - // The following code is similar to part of // tree_evaluator::visit_index_expression but simpler because it // handles a more restricted case.