1
0
forked from aniani/vim

patch 9.0.1184: interface of an object is not recognized when checking type

Problem:    Interface of an object is not recognized when checking type.
Solution:   Use the interface implemented by an object.
This commit is contained in:
Bram Moolenaar
2023-01-12 15:01:32 +00:00
parent 0233bdfa2b
commit a94bd9d939
5 changed files with 66 additions and 1 deletions

View File

@@ -876,11 +876,21 @@ check_type_maybe(
}
else if (expected->tt_type == VAR_OBJECT)
{
// check the class, base class or an implemented interface matches
class_T *cl;
for (cl = (class_T *)actual->tt_member; cl != NULL;
cl = cl->class_extends)
{
if ((class_T *)expected->tt_member == cl)
break;
int i;
for (i = cl->class_interface_count - 1; i >= 0; --i)
if ((class_T *)expected->tt_member
== cl->class_interfaces_cl[i])
break;
if (i >= 0)
break;
}
if (cl == NULL)
ret = FAIL;
}