patch 9.1.0261: Vim9: protected class and funcrefs accessible outside the class

Problem:  Vim9: protected class and funcrefs accessible outside the class
          (Aliaksei Budavei)
Solution: Check if class and object funcrefs are protected
          (Yegappan)

closes: #14407

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/vim9class.c b/src/vim9class.c
index fc4e002..11e952c 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -2835,6 +2835,14 @@
 	    return FAIL;
 	}
 
+	if (*name == '_')
+	{
+	    // Protected object or class funcref variable
+	    semsg(_(e_cannot_access_protected_variable_str), ocm->ocm_name,
+		    cl->class_name);
+	    return FAIL;
+	}
+
 	if (rettv->v_type == VAR_OBJECT)
 	{
 	    // funcref object variable