mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1888: Vim9: Problem trying to invoke class method
Problem: Vim9: Problem trying to invoke class method Solution: Lookup the class method insider other classes closes: #13055 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
23c92d93c1
commit
342f4f626e
@@ -775,6 +775,8 @@ compile_load(
|
||||
}
|
||||
else if ((idx = class_member_index(*arg, len, &cl, cctx)) >= 0)
|
||||
{
|
||||
// Referencing a class member without the class name. Infer
|
||||
// the class from the def function context.
|
||||
res = generate_CLASSMEMBER(cctx, TRUE, cl, idx);
|
||||
}
|
||||
else
|
||||
@@ -1118,6 +1120,9 @@ compile_call(
|
||||
if (lookup_local(namebuf, varlen, NULL, cctx) == FAIL
|
||||
&& arg_exists(namebuf, varlen, NULL, NULL, NULL, cctx) != OK)
|
||||
{
|
||||
class_T *cl = NULL;
|
||||
int mi = 0;
|
||||
|
||||
// If we can find the function by name generate the right call.
|
||||
// Skip global functions here, a local funcref takes precedence.
|
||||
ufunc = find_func(name, FALSE);
|
||||
@@ -1136,6 +1141,16 @@ compile_call(
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
else if ((mi = class_method_index(name, varlen, &cl, cctx)) >= 0)
|
||||
{
|
||||
// Class method invocation without the class name. The
|
||||
// generate_CALL() function expects the class type at the top of
|
||||
// the stack. So push the class type to the stack.
|
||||
push_type_stack(cctx, &t_class);
|
||||
res = generate_CALL(cctx, cl->class_class_functions[mi], NULL, 0,
|
||||
type, argcount);
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
|
||||
// If the name is a variable, load it and use PCALL.
|
||||
|
Reference in New Issue
Block a user