mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1296: calling an object method with arguments does not work
Problem: Calling an object method with arguments does not work. (Ernie Rael) Solution: Take the argument count into account when looking up the object. (closes #11911)
This commit is contained in:
@@ -1373,6 +1373,47 @@ def Test_class_extends()
|
|||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_using_base_class()
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
class BaseEE
|
||||||
|
def Enter(): any
|
||||||
|
return null
|
||||||
|
enddef
|
||||||
|
def Exit(resource: any): void
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class ChildEE extends BaseEE
|
||||||
|
def Enter(): any
|
||||||
|
return 42
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Exit(resource: number): void
|
||||||
|
g:result ..= '/exit'
|
||||||
|
enddef
|
||||||
|
endclass
|
||||||
|
|
||||||
|
def With(ee: BaseEE)
|
||||||
|
var r = ee.Enter()
|
||||||
|
try
|
||||||
|
g:result ..= r
|
||||||
|
finally
|
||||||
|
g:result ..= '/finally'
|
||||||
|
ee.Exit(r)
|
||||||
|
endtry
|
||||||
|
enddef
|
||||||
|
|
||||||
|
g:result = ''
|
||||||
|
With(ChildEE.new())
|
||||||
|
assert_equal('42/finally/exit', g:result)
|
||||||
|
END
|
||||||
|
v9.CheckScriptSuccess(lines)
|
||||||
|
unlet g:result
|
||||||
|
enddef
|
||||||
|
|
||||||
|
|
||||||
def Test_class_import()
|
def Test_class_import()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1296,
|
||||||
/**/
|
/**/
|
||||||
1295,
|
1295,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -4143,8 +4143,10 @@ exec_instructions(ectx_T *ectx)
|
|||||||
// call a method on an interface
|
// call a method on an interface
|
||||||
case ISN_METHODCALL:
|
case ISN_METHODCALL:
|
||||||
{
|
{
|
||||||
|
cmfunc_T *mfunc = iptr->isn_arg.mfunc;
|
||||||
|
|
||||||
SOURCING_LNUM = iptr->isn_lnum;
|
SOURCING_LNUM = iptr->isn_lnum;
|
||||||
tv = STACK_TV_BOT(-1);
|
tv = STACK_TV_BOT(-1 - mfunc->cmf_argcount);
|
||||||
if (tv->v_type != VAR_OBJECT)
|
if (tv->v_type != VAR_OBJECT)
|
||||||
{
|
{
|
||||||
object_required_error(tv);
|
object_required_error(tv);
|
||||||
@@ -4154,7 +4156,6 @@ exec_instructions(ectx_T *ectx)
|
|||||||
class_T *cl = obj->obj_class;
|
class_T *cl = obj->obj_class;
|
||||||
|
|
||||||
// convert the interface index to the object index
|
// convert the interface index to the object index
|
||||||
cmfunc_T *mfunc = iptr->isn_arg.mfunc;
|
|
||||||
int idx = object_index_from_itf_index(mfunc->cmf_itf,
|
int idx = object_index_from_itf_index(mfunc->cmf_itf,
|
||||||
TRUE, mfunc->cmf_idx, cl);
|
TRUE, mfunc->cmf_idx, cl);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user