mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.1292: :defer may call the wrong method for an object
Problem: :defer may call the wrong method for an object. (Ernie Rael) Solution: When en object is from a class that extends or implements, figure out the method to call at runtime. (closes #11910)
This commit is contained in:
@@ -4291,7 +4291,24 @@ exec_instructions(ectx_T *ectx)
|
||||
vim_free(pt);
|
||||
goto theend;
|
||||
}
|
||||
if (extra == NULL || extra->fre_func_name == NULL)
|
||||
if (extra != NULL && extra->fre_class != NULL)
|
||||
{
|
||||
tv = STACK_TV_BOT(-1);
|
||||
if (tv->v_type != VAR_OBJECT)
|
||||
{
|
||||
object_required_error(tv);
|
||||
vim_free(pt);
|
||||
goto on_error;
|
||||
}
|
||||
object_T *obj = tv->vval.v_object;
|
||||
class_T *cl = obj->obj_class;
|
||||
|
||||
// convert the interface index to the object index
|
||||
int idx = object_index_from_itf_index(extra->fre_class,
|
||||
TRUE, extra->fre_method_idx, cl);
|
||||
ufunc = cl->class_obj_methods[idx];
|
||||
}
|
||||
else if (extra == NULL || extra->fre_func_name == NULL)
|
||||
{
|
||||
dfunc_T *pt_dfunc = ((dfunc_T *)def_functions.ga_data)
|
||||
+ funcref->fr_dfunc_idx;
|
||||
@@ -4299,7 +4316,9 @@ exec_instructions(ectx_T *ectx)
|
||||
ufunc = pt_dfunc->df_ufunc;
|
||||
}
|
||||
else
|
||||
{
|
||||
ufunc = find_func(extra->fre_func_name, FALSE);
|
||||
}
|
||||
if (ufunc == NULL)
|
||||
{
|
||||
SOURCING_LNUM = iptr->isn_lnum;
|
||||
@@ -6727,8 +6746,16 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
|
||||
}
|
||||
else
|
||||
name = extra->fre_func_name;
|
||||
if (extra == NULL || extra->fre_loopvar_info.lvi_depth == 0)
|
||||
if (extra != NULL && extra->fre_class != NULL)
|
||||
{
|
||||
smsg("%s%4d FUNCREF %s.%s", pfx, current,
|
||||
extra->fre_class->class_name, name);
|
||||
}
|
||||
else if (extra == NULL
|
||||
|| extra->fre_loopvar_info.lvi_depth == 0)
|
||||
{
|
||||
smsg("%s%4d FUNCREF %s", pfx, current, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
char_u *info = printable_loopvarinfo(
|
||||
|
Reference in New Issue
Block a user