v9.CheckSourceSuccess(lines)
enddef
+" Test for implementing an interface with different ordering for the interface
+" member variables.
+def Test_implement_interface_with_different_variable_order()
+ var lines =<< trim END
+ vim9script
+
+ interface IX
+ var F: func(): string
+ endinterface
+
+ class X implements IX
+ var x: number
+ var F: func(): string = () => 'ok'
+ endclass
+
+ def Foo(ix: IX): string
+ return ix.F()
+ enddef
+
+ var x0 = X.new(0)
+ assert_equal('ok', Foo(x0))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
" Test for using "any" type for a variable in a sub-class while it has a
" concrete type in the interface
def Test_implements_using_var_type_any()
unlet g:instr
enddef
+" Disassemble the code generated for accessing a interface member variable
+def Test_disassemble_interface_variable_access()
+ var lines =<< trim END
+ vim9script
+ interface IX
+ var F: func(): string
+ endinterface
+
+ def Foo(ix: IX): string
+ return ix.F()
+ enddef
+
+ g:instr = execute('disassemble Foo')
+ END
+ v9.CheckScriptSuccess(lines)
+ assert_match('<SNR>\d\+_Foo\_s*' ..
+ 'return ix.F()\_s*' ..
+ '0 LOAD arg\[-1\]\_s*' ..
+ '1 ITF_MEMBER 0 on IX\_s*' ..
+ '2 PCALL top (argc 0)\_s*' ..
+ '3 PCALL end\_s*' ..
+ '4 RETURN', g:instr)
+ unlet g:instr
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1002,
/**/
1001,
/**/
}
else
{
- if (generate_GET_OBJ_MEMBER(cctx, m_idx, ocm->ocm_type) ==
- FAIL)
+ int status;
+
+ if (IS_INTERFACE(cl))
+ status = generate_GET_ITF_MEMBER(cctx, cl, m_idx,
+ ocm->ocm_type);
+ else
+ status = generate_GET_OBJ_MEMBER(cctx, m_idx,
+ ocm->ocm_type);
+ if (status == FAIL)
return FAIL;
}
}