patch 9.1.0673: Vim9: too recursive func calls when calling super-class method
Problem: Vim9: too recursive func calls when calling super-class method
with non-overriden super-call methods. (Aliaksei Budavei)
Solution: use interface method, when super is to be used (Ernie Rael)
When compiling "super.Func()" force class context to class that defines
function that is doing "super.Func()".
ISN_METHODCALL arg "cmf_is_super" for specific ufunc.
fixes: #15448
fixes: #15463 (2) super.method may not execute in context of defining
class
closes: #15477
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 40b5499..f523e27 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -4400,14 +4400,23 @@
goto on_error;
}
- class_T *cl = obj->obj_class;
+ ufunc_T *ufunc;
+ if (mfunc->cmf_is_super)
+ // Doing "super.Func", use the specific ufunc.
+ ufunc = mfunc->cmf_itf->class_obj_methods[
+ mfunc->cmf_idx];
+ else
+ {
+ class_T *cl = obj->obj_class;
- // convert the interface index to the object index
- int idx = object_index_from_itf_index(mfunc->cmf_itf,
- TRUE, mfunc->cmf_idx, cl);
+ // convert the interface index to the object index
+ int idx = object_index_from_itf_index(mfunc->cmf_itf,
+ TRUE, mfunc->cmf_idx, cl);
+ ufunc = cl->class_obj_methods[idx];
+ }
- if (call_ufunc(cl->class_obj_methods[idx], NULL,
- mfunc->cmf_argcount, ectx, NULL, NULL) == FAIL)
+ if (call_ufunc(ufunc, NULL, mfunc->cmf_argcount, ectx,
+ NULL, NULL) == FAIL)
goto on_error;
}
break;