summaryrefslogtreecommitdiffstats
path: root/src/vim9type.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-01-12 15:01:32 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-12 15:01:32 +0000
commita94bd9d9396183eb7781f8d6a5a0e6e97442e9ed (patch)
tree905c544e79e96f25a5a164416338b93952c5eb85 /src/vim9type.c
parent0233bdfa2b487c392dc4fd1a29113e08fbace334 (diff)
patch 9.0.1184: interface of an object is not recognized when checking typev9.0.1184
Problem: Interface of an object is not recognized when checking type. Solution: Use the interface implemented by an object.
Diffstat (limited to 'src/vim9type.c')
-rw-r--r--src/vim9type.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/vim9type.c b/src/vim9type.c
index 5d3f815b50..02b674d23c 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -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;
}