call v9.CheckSourceSuccess(lines)
endfunc
+" Test if class members can be accessed via a lambda inside a object/class
+" method.
+func Test_class_member_lambda()
+ let lines =<< trim END
+ vim9script
+ class A
+ static var regular: string
+ static var _protected: string
+
+ static def RegularMethod(): string
+ return A.regular
+ enddef
+
+ static def _ProtectedMethod(): string
+ return A._protected
+ enddef
+
+ def new()
+ var FuncA: func = () => {
+ A.regular = "regular"
+ assert_equal("regular", A.RegularMethod())
+ }
+ var FuncB: func = () => {
+ A._protected = "protected"
+ assert_equal("protected", A._ProtectedMethod())
+ }
+
+ FuncA()
+ FuncB()
+ enddef
+ endclass
+
+ A.new()
+ END
+ call v9.CheckSourceSuccess(lines)
+endfunc
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2032,
/**/
2031,
/**/
// only inside the class where it is defined.
if ((m->ocm_access != VIM_ACCESS_ALL) &&
((is_object && !inside_class(cctx, cl))
- || (!is_object && cctx->ctx_ufunc->uf_class != cl)))
+ || (!is_object && cctx->ctx_ufunc->uf_defclass != cl)))
{
char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
? e_cannot_access_protected_variable_str
((type->tt_type == VAR_OBJECT
&& !inside_class_hierarchy(cctx, cl))
|| (type->tt_type == VAR_CLASS
- && cctx->ctx_ufunc->uf_class != cl)))
+ && cctx->ctx_ufunc->uf_defclass != cl)))
{
semsg(_(e_cannot_access_protected_method_str), name);
goto done;