1
0
forked from aniani/vim

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:
Bram Moolenaar
2023-02-08 20:55:27 +00:00
parent 6642982bea
commit 313e4724c3
8 changed files with 94 additions and 9 deletions

View File

@@ -383,7 +383,12 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
// uf_name[] only being 4 characters.
char_u *ufname = (char_u *)fp->uf_name;
if (STRNCMP(name, ufname, len) == 0 && ufname[len] == NUL)
return generate_FUNCREF(cctx, fp, NULL);
{
if (type->tt_type == VAR_OBJECT
&& (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED)))
return generate_FUNCREF(cctx, fp, cl, i, NULL);
return generate_FUNCREF(cctx, fp, NULL, 0, NULL);
}
}
semsg(_(e_member_not_found_on_object_str_str), cl->class_name, name);
@@ -1308,7 +1313,7 @@ compile_lambda(char_u **arg, cctx_T *cctx)
// The function reference count will be 1. When the ISN_FUNCREF
// instruction is deleted the reference count is decremented and the
// function is freed.
return generate_FUNCREF(cctx, ufunc, NULL);
return generate_FUNCREF(cctx, ufunc, NULL, 0, NULL);
}
func_ptr_unref(ufunc);