patch 9.0.1209: getting interface member does not always work
Problem: Getting interface member does not always work.
Solution: Convert the index on the interface to the index on the object.
(closes #11825)
diff --git a/src/vim9instr.c b/src/vim9instr.c
index 118e885..89f1243 100644
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -150,6 +150,26 @@
}
/*
+ * Generate ISN_GET_ITF_MEMBER - access member of interface at bottom of stack
+ * by index.
+ */
+ int
+generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type)
+{
+ RETURN_OK_IF_SKIP(cctx);
+
+ // drop the object type
+ isn_T *isn = generate_instr_drop(cctx, ISN_GET_ITF_MEMBER, 1);
+ if (isn == NULL)
+ return FAIL;
+
+ isn->isn_arg.classmember.cm_class = itf;
+ ++itf->class_refcount;
+ isn->isn_arg.classmember.cm_idx = idx;
+ return push_type_stack2(cctx, type, &t_any);
+}
+
+/*
* Generate ISN_STORE_THIS - store value in member of "this" object with member
* index "idx".
*/
@@ -2497,6 +2517,7 @@
case ISN_LOAD_CLASSMEMBER:
case ISN_STORE_CLASSMEMBER:
+ case ISN_GET_ITF_MEMBER:
class_unref(isn->isn_arg.classmember.cm_class);
break;