Problem: Using an interface method may give a compilation error.
Solution: Do not try to compile the body of a method of an interface.
(closes #11885)
unlet g:result
END
v9.CheckScriptSuccess(lines)
+
+ # No class that implements the interface.
+ lines =<< trim END
+ vim9script
+
+ interface IWithEE
+ def Enter(): any
+ def Exit(): void
+ endinterface
+
+ def With1(ee: IWithEE, F: func)
+ var r = ee.Enter()
+ enddef
+
+ defcompile
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_class_used_as_type()
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1265,
/**/
1264,
/**/
}
ufunc->uf_args_visible = ufunc->uf_args.ga_len;
+ // Compiling a function in an interface is done to get the function type.
+ // No code is actually compiled.
+ if (ufunc->uf_class != NULL
+ && (ufunc->uf_class->class_flags & CLASS_INTERFACE))
+ {
+ ufunc->uf_def_status = UF_NOT_COMPILED;
+ ret = OK;
+ goto erret;
+ }
+
/*
* Loop over all the lines of the function and generate instructions.
*/
iemsg("Type stack underflow");
goto erret;
}
- }
+ } // END of the loop over all the function body lines.
if (cctx.ctx_scope != NULL)
{