patch 9.1.1094: Vim9: problem finding implemented method in type hierarchy
Problem: Vim9: problem finding implemented method for abstract method
in type hierarchy (Aliaksei Budavei)
Solution: When checking for abstract methods in an extended class, check
whether an abstract method is implemented in one of the parent
classes (Yegappan Lakshmanan)
fixes: #16495
closes: #16497
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/vim9class.c b/src/vim9class.c
index e847bf0..47ab236 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -561,20 +561,34 @@
if (!IS_ABSTRACT_METHOD(uf))
continue;
- int method_found = FALSE;
+ int concrete_method_found = FALSE;
+ int j = 0;
- for (int j = 0; j < method_count; j++)
+ // Check if the abstract method is already implemented in one of
+ // the parent classes.
+ for (j = 0; !concrete_method_found && j < i; j++)
+ {
+ ufunc_T *uf2 = extends_methods[j];
+ if (!IS_ABSTRACT_METHOD(uf2) &&
+ STRCMP(uf->uf_name, uf2->uf_name) == 0)
+ concrete_method_found = TRUE;
+ }
+
+ if (concrete_method_found)
+ continue;
+
+ for (j = 0; j < method_count; j++)
{
if (STRCMP(uf->uf_name, cl_fp[j]->uf_name) == 0)
{
- method_found = TRUE;
+ concrete_method_found = TRUE;
break;
}
}
- if (!method_found)
+ if (!concrete_method_found)
{
- semsg(_(e_abstract_method_str_not_found), uf->uf_name);
+ semsg(_(e_abstract_method_str_not_implemented), uf->uf_name);
return FALSE;
}
}