mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.1880: Vim9: Need more tests for inheritance
Problem: Vim9: Need more tests for inheritance Solution: Add access tests and fixes. `inside_class` fix from yegappan. `object_index_from_itf_index` fix access of member on class extending class implementing interface. Based on tests from Vim9: Class/Object member variable access control #12979 closes: #13032 related: #12979 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
f7ac0ef509
commit
cf138d4ea5
@@ -237,10 +237,16 @@ object_index_from_itf_index(class_T *itf, int is_method, int idx, class_T *cl,
|
||||
if (cl == itf)
|
||||
return idx;
|
||||
|
||||
itf2class_T *i2c;
|
||||
for (i2c = itf->class_itf2class; i2c != NULL; i2c = i2c->i2c_next)
|
||||
if (i2c->i2c_class == cl && i2c->i2c_is_method == is_method)
|
||||
break;
|
||||
itf2class_T *i2c = NULL;
|
||||
int searching = TRUE;
|
||||
for (class_T *super = cl; super != NULL && searching;
|
||||
super = super->class_extends)
|
||||
for (i2c = itf->class_itf2class; i2c != NULL; i2c = i2c->i2c_next)
|
||||
if (i2c->i2c_class == super && i2c->i2c_is_method == is_method)
|
||||
{
|
||||
searching = FALSE;
|
||||
break;
|
||||
}
|
||||
if (i2c == NULL)
|
||||
{
|
||||
siemsg("class %s not found on interface %s",
|
||||
@@ -1978,7 +1984,8 @@ class_member_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx)
|
||||
inside_class(cctx_T *cctx_arg, class_T *cl)
|
||||
{
|
||||
for (cctx_T *cctx = cctx_arg; cctx != NULL; cctx = cctx->ctx_outer)
|
||||
if (cctx->ctx_ufunc != NULL && cctx->ctx_ufunc->uf_class == cl)
|
||||
if (cctx->ctx_ufunc != NULL
|
||||
&& class_instance_of(cctx->ctx_ufunc->uf_class, cl))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user