v9.CheckScriptSuccess(lines)
enddef
+" Test for calling a method in a class that is extended
+def Test_call_method_in_extended_class()
+ var lines =<< trim END
+ vim9script
+
+ var prop_init_called = false
+ var prop_register_called = false
+
+ class Property
+ def Init()
+ prop_init_called = true
+ enddef
+
+ def Register()
+ prop_register_called = true
+ enddef
+ endclass
+
+ class Bool extends Property
+ endclass
+
+ def Observe(obj: Property)
+ obj.Register()
+ enddef
+
+ var p = Property.new()
+ Observe(p)
+
+ p.Init()
+ assert_true(prop_init_called)
+ assert_true(prop_register_called)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
siemsg("index %d out of range for interface %s", idx, itf->class_name);
return 0;
}
+
+ // If "cl" is the interface or the class that is extended, then the method
+ // index can be used directly and there is no need to search for the method
+ // index in one of the child classes.
+ 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)