patch 9.0.2096: Vim9: confusing usage of private

Problem:  Vim9: confusing usage of private
Solution: clarify and use protected keyword instead

[vim9class] document `_` as protected instead of private

fixes #13504
closes: #13520

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/errors.h b/src/errors.h
index 85439ba..4424337 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3410,8 +3410,8 @@
 	INIT(= N_("E1331: Public must be followed by \"this\" or \"static\""));
 EXTERN char e_public_variable_name_cannot_start_with_underscore_str[]
 	INIT(= N_("E1332: Public variable name cannot start with underscore: %s"));
-EXTERN char e_cannot_access_private_variable_str[]
-	INIT(= N_("E1333: Cannot access private variable \"%s\" in class \"%s\""));
+EXTERN char e_cannot_access_protected_variable_str[]
+	INIT(= N_("E1333: Cannot access protected variable \"%s\" in class \"%s\""));
 // E1334 unused
 EXTERN char e_variable_is_not_writable_str[]
 	INIT(= N_("E1335: Variable \"%s\" in class \"%s\" is not writable"));
@@ -3484,8 +3484,8 @@
 #ifdef FEAT_EVAL
 EXTERN char e_cannot_use_a_return_type_with_new_method[]
 	INIT(= N_("E1365: Cannot use a return type with the \"new\" method"));
-EXTERN char e_cannot_access_private_method_str[]
-	INIT(= N_("E1366: Cannot access private method: %s"));
+EXTERN char e_cannot_access_protected_method_str[]
+	INIT(= N_("E1366: Cannot access protected method: %s"));
 EXTERN char e_variable_str_of_interface_str_has_different_access[]
 	INIT(= N_("E1367: Access level of variable \"%s\" of interface \"%s\" is different"));
 EXTERN char e_static_cannot_be_followed_by_this[]
@@ -3510,10 +3510,10 @@
 	INIT(= N_("E1377: Access level of method \"%s\" is different in class \"%s\""));
 EXTERN char e_static_member_not_supported_in_interface[]
 	INIT(= N_("E1378: Static member not supported in an interface"));
-EXTERN char e_private_variable_not_supported_in_interface[]
-	INIT(= N_("E1379: Private variable not supported in an interface"));
-EXTERN char e_private_method_not_supported_in_interface[]
-	INIT(= N_("E1380: Private method not supported in an interface"));
+EXTERN char e_protected_variable_not_supported_in_interface[]
+	INIT(= N_("E1379: Protected variable not supported in an interface"));
+EXTERN char e_protected_method_not_supported_in_interface[]
+	INIT(= N_("E1380: Protected method not supported in an interface"));
 EXTERN char e_interface_cannot_use_implements[]
 	INIT(= N_("E1381: Interface cannot use \"implements\""));
 EXTERN char e_variable_str_type_mismatch_expected_str_but_got_str[]
diff --git a/src/eval.c b/src/eval.c
index ea57cde..0579a85 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1112,7 +1112,7 @@
 	switch (om->ocm_access)
 	{
 	    case VIM_ACCESS_PRIVATE:
-		msg = e_cannot_access_private_variable_str;
+		msg = e_cannot_access_protected_variable_str;
 		break;
 	    case VIM_ACCESS_READ:
 		// If [idx] or .key following, read only OK.
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index 1f639e2..18fde09 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -324,7 +324,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3)
 
-  # Using the "public" keyword when defining an object private method
+  # Using the "public" keyword when defining an object protected method
   lines =<< trim END
     vim9script
     class A
@@ -334,7 +334,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "this" or "static"', 3)
 
-  # Using the "public" keyword when defining a class private method
+  # Using the "public" keyword when defining a class protected method
   lines =<< trim END
     vim9script
     class A
@@ -606,7 +606,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Try modifying a private variable using an "any" object
+  # Try modifying a protected variable using an "any" object
   lines =<< trim END
     vim9script
 
@@ -626,7 +626,7 @@
     var outer_obj = Outer.new(inner_obj)
     F(outer_obj)
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_value" in class "Inner"', 1)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_value" in class "Inner"', 1)
 
   # Try modifying a non-existing variable using an "any" object
   lines =<< trim END
@@ -1085,9 +1085,9 @@
     assert_equal(1, trip.GetOne())
     assert_equal(2, trip.two)
     assert_equal(3, trip.three)
-    assert_fails('echo trip._one', 'E1333: Cannot access private variable "_one" in class "Triple"')
+    assert_fails('echo trip._one', 'E1333: Cannot access protected variable "_one" in class "Triple"')
 
-    assert_fails('trip._one = 11', 'E1333: Cannot access private variable "_one" in class "Triple"')
+    assert_fails('trip._one = 11', 'E1333: Cannot access protected variable "_one" in class "Triple"')
     assert_fails('trip.two = 22', 'E1335: Variable "two" in class "Triple" is not writable')
     trip.three = 33
     assert_equal(33, trip.three)
@@ -1321,7 +1321,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1335: Variable "ro_class_var" in class "A" is not writable', 1)
 
-  # A private class variable cannot be accessed from a child class
+  # A protected class variable cannot be accessed from a child class
   lines =<< trim END
     vim9script
     class A
@@ -1337,9 +1337,9 @@
     var b = B.new()
     b.Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_priv_class_var" in class "A"', 1)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_priv_class_var" in class "A"', 1)
 
-  # A private class variable cannot be modified from a child class
+  # A protected class variable cannot be modified from a child class
   lines =<< trim END
     vim9script
     class A
@@ -1355,7 +1355,7 @@
     var b = B.new()
     b.Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_priv_class_var" in class "A"', 1)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_priv_class_var" in class "A"', 1)
 
   # Access from child class extending a class and from script context
   lines =<< trim END
@@ -1536,8 +1536,8 @@
     assert_fails('TextPos.counter = 5', 'E1335: Variable "counter" in class "TextPos" is not writable')
     assert_fails('TextPos.counter += 5', 'E1335: Variable "counter" in class "TextPos" is not writable')
 
-    assert_fails('echo TextPos._secret', 'E1333: Cannot access private variable "_secret" in class "TextPos"')
-    assert_fails('TextPos._secret = 8', 'E1333: Cannot access private variable "_secret" in class "TextPos"')
+    assert_fails('echo TextPos._secret', 'E1333: Cannot access protected variable "_secret" in class "TextPos"')
+    assert_fails('TextPos._secret = 8', 'E1333: Cannot access protected variable "_secret" in class "TextPos"')
 
     assert_equal(42, TextPos.anybody)
     TextPos.anybody = 12
@@ -1583,7 +1583,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # access private member in lambda
+  # access protected member in lambda
   lines =<< trim END
     vim9script
 
@@ -1601,7 +1601,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # access private member in lambda body
+  # access protected member in lambda body
   lines =<< trim END
     vim9script
 
@@ -1762,7 +1762,7 @@
     var o = Child.new()
     var x = o._v1
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_v1" in class "Base"', 11)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_v1" in class "Base"', 11)
   lines =<< trim END
     vim9script
 
@@ -1779,7 +1779,7 @@
     enddef
     F()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_v1" in class "Base"', 2)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_v1" in class "Base"', 2)
   lines =<< trim END
     vim9script
 
@@ -1811,7 +1811,7 @@
     F()
   END
 
-  # Attempt to read a private variable that is in the middle
+  # Attempt to read a protected variable that is in the middle
   # of the class hierarchy.
   v9.CheckSourceFailure(lines, 'E1335: Variable "v1" in class "Base" is not writable', 2)
   lines =<< trim END
@@ -1833,9 +1833,9 @@
     enddef
     F()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_v1" in class "Base"', 2)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_v1" in class "Base"', 2)
 
-  # Attempt to read a private variable that is at the start
+  # Attempt to read a protected variable that is at the start
   # of the class hierarchy.
   lines =<< trim END
     vim9script
@@ -1856,7 +1856,7 @@
     enddef
     F()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_v1" in class "Child"', 2)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_v1" in class "Child"', 2)
 enddef
 
 func Test_class_garbagecollect()
@@ -4132,7 +4132,7 @@
   END
   v9.CheckSourceFailure(lines, 'E741: Value is locked: l[0] = 11', 11)
 
-  # lock a list element referenced by a private object variable
+  # lock a list element referenced by a protected object variable
   # in an object fetched via a script level list
   lines =<< trim END
     vim9script
@@ -4155,8 +4155,8 @@
   v9.CheckSourceFailure(lines, 'E741: Value is locked: l[1] = [33]', 16)
 
   # similar to the previous test, except the locking code is executing
-  # in a class that does not own the private variable.
-  # Note that the locking code is in a class has a private variable of
+  # in a class that does not own the protected variable.
+  # Note that the locking code is in a class has a protected variable of
   # the same name.
   lines =<< trim END
     vim9script
@@ -4179,7 +4179,7 @@
     var o2 = C2.new()
     o2.Lock(o)
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_v1" in class "C"')
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_v1" in class "C"')
 enddef
 
 " Test builtin islocked()
@@ -4503,9 +4503,9 @@
   v9.CheckSourceSuccess(lines)
 enddef
 
-" Test for a private object method
+" Test for a protected object method
 def Test_private_object_method()
-  # Try calling a private method using an object (at the script level)
+  # Try calling a protected method using an object (at the script level)
   var lines =<< trim END
     vim9script
 
@@ -4517,9 +4517,9 @@
     var a = A.new()
     a._Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 9)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 9)
 
-  # Try calling a private method using an object (from a def function)
+  # Try calling a protected method using an object (from a def function)
   lines =<< trim END
     vim9script
 
@@ -4534,9 +4534,9 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 2)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 2)
 
-  # Use a private method from another object method (in script context)
+  # Use a protected method from another object method (in script context)
   lines =<< trim END
     vim9script
 
@@ -4553,7 +4553,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Use a private method from another object method (def function context)
+  # Use a protected method from another object method (def function context)
   lines =<< trim END
     vim9script
 
@@ -4573,7 +4573,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Try calling a private method without the "this" prefix
+  # Try calling a protected method without the "this" prefix
   lines =<< trim END
     vim9script
 
@@ -4590,7 +4590,7 @@
   END
   v9.CheckSourceFailure(lines, 'E117: Unknown function: _Foo', 1)
 
-  # Try calling a private method using the class name
+  # Try calling a protected method using the class name
   lines =<< trim END
     vim9script
 
@@ -4601,9 +4601,9 @@
     endclass
     A._Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 8)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 8)
 
-  # Define two private methods with the same name
+  # Define two protected methods with the same name
   lines =<< trim END
     vim9script
 
@@ -4617,7 +4617,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 7)
 
-  # Define a private method and a object method with the same name
+  # Define a protected method and a object method with the same name
   lines =<< trim END
     vim9script
 
@@ -4631,7 +4631,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 7)
 
-  # Define an object method and a private method with the same name
+  # Define an object method and a protected method with the same name
   lines =<< trim END
     vim9script
 
@@ -4645,7 +4645,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 7)
 
-  # Call a public method and a private method from a private method
+  # Call a public method and a protected method from a protected method
   lines =<< trim END
     vim9script
 
@@ -4669,7 +4669,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Try calling a private method from another class
+  # Try calling a protected method from another class
   lines =<< trim END
     vim9script
 
@@ -4687,9 +4687,9 @@
     var b = B.new()
     b.Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 2)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 2)
 
-  # Call a private object method from a child class object method
+  # Call a protected object method from a child class object method
   lines =<< trim END
     vim9script
     class A
@@ -4711,7 +4711,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Call a private object method from a child class object
+  # Call a protected object method from a child class object
   lines =<< trim END
     vim9script
     class A
@@ -4730,7 +4730,7 @@
     var c = C.new()
     assert_equal(1234, c._Foo())
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 16)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 16)
 
   # Using "_" prefix in a method name should fail outside of a class
   lines =<< trim END
@@ -4743,9 +4743,9 @@
   v9.CheckSourceFailure(lines, 'E1267: Function name must start with a capital: _Foo(): number', 2)
 enddef
 
-" Test for an private class method
+" Test for an protected class method
 def Test_private_class_method()
-  # Try calling a class private method (at the script level)
+  # Try calling a class protected method (at the script level)
   var lines =<< trim END
     vim9script
 
@@ -4756,9 +4756,9 @@
     endclass
     A._Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 8)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 8)
 
-  # Try calling a class private method (from a def function)
+  # Try calling a class protected method (from a def function)
   lines =<< trim END
     vim9script
 
@@ -4772,9 +4772,9 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 1)
 
-  # Try calling a class private method using an object (at the script level)
+  # Try calling a class protected method using an object (at the script level)
   lines =<< trim END
     vim9script
 
@@ -4786,9 +4786,9 @@
     var a = A.new()
     a._Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 9)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 9)
 
-  # Try calling a class private method using an object (from a def function)
+  # Try calling a class protected method using an object (from a def function)
   lines =<< trim END
     vim9script
 
@@ -4803,9 +4803,9 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 2)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 2)
 
-  # Use a class private method from an object method
+  # Use a class protected method from an object method
   lines =<< trim END
     vim9script
 
@@ -4822,7 +4822,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Use a class private method from another class private method without the
+  # Use a class protected method from another class protected method without the
   # class name prefix.
   lines =<< trim END
     vim9script
@@ -4843,7 +4843,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Declare a class method and a class private method with the same name
+  # Declare a class method and a class protected method with the same name
   lines =<< trim END
     vim9script
 
@@ -4857,7 +4857,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 7)
 
-  # Try calling a class private method from another class
+  # Try calling a class protected method from another class
   lines =<< trim END
     vim9script
 
@@ -4874,9 +4874,9 @@
     var b = B.new()
     assert_equal(1234, b.Foo())
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 1)
 
-  # Call a private class method from a child class object method
+  # Call a protected class method from a child class object method
   lines =<< trim END
     vim9script
     class A
@@ -4896,9 +4896,9 @@
     var c = C.new()
     assert_equal(1234, c.Baz())
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 1)
 
-  # Call a private class method from a child class private class method
+  # Call a protected class method from a child class protected class method
   lines =<< trim END
     vim9script
     class A
@@ -4917,9 +4917,9 @@
     endclass
     assert_equal(1234, C.Baz())
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo()', 1)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo()', 1)
 
-  # Call a private class method from a child class object
+  # Call a protected class method from a child class object
   lines =<< trim END
     vim9script
     class A
@@ -5032,7 +5032,7 @@
     assert_equal(102, ob.AccessObject())
     assert_equal(103, oc.AccessObject())
 
-    assert_fails('echo oc.AccessPrivateStaticThroughClassName()', 'E1333: Cannot access private variable "_svar" in class "A"')
+    assert_fails('echo oc.AccessPrivateStaticThroughClassName()', 'E1333: Cannot access protected variable "_svar" in class "A"')
 
     # verify object properly resolves to correct static
     assert_equal(1, oa.AccessStaticThroughObject())
@@ -5054,7 +5054,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4)
 
-  # Duplicate private member variable
+  # Duplicate protected member variable
   lines =<< trim END
     vim9script
     class C
@@ -5074,7 +5074,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 4)
 
-  # Duplicate private member variable
+  # Duplicate protected member variable
   lines =<< trim END
     vim9script
     class C
@@ -5084,7 +5084,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 4)
 
-  # Duplicate public and private member variable
+  # Duplicate public and protected member variable
   lines =<< trim END
     vim9script
     class C
@@ -5104,7 +5104,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _s', 4)
 
-  # Duplicate public and private class member variable
+  # Duplicate public and protected class member variable
   lines =<< trim END
     vim9script
     class C
@@ -5143,7 +5143,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: val', 9)
 
-  # Duplicate object private member variable in a derived class
+  # Duplicate object protected member variable in a derived class
   lines =<< trim END
     vim9script
     class A
@@ -5157,7 +5157,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: _val', 9)
 
-  # Duplicate object private member variable in a derived class
+  # Duplicate object protected member variable in a derived class
   lines =<< trim END
     vim9script
     class A
@@ -5196,9 +5196,9 @@
   v9.CheckSourceSuccess(lines)
 enddef
 
-" Test for accessing a private member outside a class in a def function
+" Test for accessing a protected member outside a class in a def function
 def Test_private_member_access_outside_class()
-  # private object member variable
+  # protected object member variable
   var lines =<< trim END
     vim9script
     class A
@@ -5213,9 +5213,9 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_val" in class "A"', 2)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 2)
 
-  # access a non-existing private object member variable
+  # access a non-existing protected object member variable
   lines =<< trim END
     vim9script
     class A
@@ -5229,7 +5229,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1326: Variable "_a" not found in object "A"', 2)
 
-  # private static member variable
+  # protected static member variable
   lines =<< trim END
     vim9script
     class A
@@ -5243,7 +5243,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2)
 
-  # private static member variable
+  # protected static member variable
   lines =<< trim END
     vim9script
     class A
@@ -5257,7 +5257,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1375: Class variable "_val" accessible only using class "A"', 2)
 
-  # private static class variable
+  # protected static class variable
   lines =<< trim END
     vim9script
     class A
@@ -5268,9 +5268,9 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_val" in class "A"', 1)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 1)
 
-  # private static class variable
+  # protected static class variable
   lines =<< trim END
     vim9script
     class A
@@ -5281,7 +5281,7 @@
     enddef
     T()
   END
-  v9.CheckSourceFailure(lines, 'E1333: Cannot access private variable "_val" in class "A"', 1)
+  v9.CheckSourceFailure(lines, 'E1333: Cannot access protected variable "_val" in class "A"', 1)
 enddef
 
 " Test for changing the member access of an interface in a implementation class
@@ -5342,7 +5342,7 @@
       A.var3 = {c: 3, d: 4}
       assert_equal([3, 4], A.var2)
       assert_equal({c: 3, d: 4}, A.var3)
-      assert_fails('echo A._priv_var4', 'E1333: Cannot access private variable "_priv_var4" in class "A"')
+      assert_fails('echo A._priv_var4', 'E1333: Cannot access protected variable "_priv_var4" in class "A"')
     enddef
     T()
   END
@@ -6035,7 +6035,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 6)
 
-  # Duplicate private instance method
+  # Duplicate protected instance method
   lines =<< trim END
     vim9script
     class A
@@ -6059,7 +6059,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: Foo', 6)
 
-  # Duplicate private class method
+  # Duplicate protected class method
   lines =<< trim END
     vim9script
     class A
@@ -6071,7 +6071,7 @@
   END
   v9.CheckSourceFailure(lines, 'E1355: Duplicate function: _Foo', 6)
 
-  # Duplicate private class and object method
+  # Duplicate protected class and object method
   lines =<< trim END
     vim9script
     class A
@@ -6087,7 +6087,7 @@
 " Test for an instance method access level comparison with parent instance
 " methods.
 def Test_instance_method_access_level()
-  # Private method in subclass
+  # protected method in subclass
   var lines =<< trim END
     vim9script
     class A
@@ -6147,7 +6147,7 @@
 enddef
 
 " A interface cannot have a static variable or a static method or a private
-" variable or a private method or a public variable
+" variable or a protected method or a public variable
 def Test_interface_with_unsupported_members()
   var lines =<< trim END
     vim9script
@@ -6211,7 +6211,7 @@
       this._Foo: list<string>
     endinterface
   END
-  v9.CheckSourceFailure(lines, 'E1379: Private variable not supported in an interface', 3)
+  v9.CheckSourceFailure(lines, 'E1379: Protected variable not supported in an interface', 3)
 
   lines =<< trim END
     vim9script
@@ -6219,7 +6219,7 @@
       def _Foo(d: dict<any>): list<string>
     endinterface
   END
-  v9.CheckSourceFailure(lines, 'E1380: Private method not supported in an interface', 3)
+  v9.CheckSourceFailure(lines, 'E1380: Protected method not supported in an interface', 3)
 enddef
 
 " Test for extending an interface
@@ -7653,7 +7653,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Try using a private object method funcref from a def function
+  # Try using a protected object method funcref from a def function
   lines =<< trim END
     vim9script
     class A
@@ -7666,9 +7666,9 @@
     enddef
     Bar()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 2)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 2)
 
-  # Try using a private object method funcref at the script level
+  # Try using a protected object method funcref at the script level
   lines =<< trim END
     vim9script
     class A
@@ -7678,9 +7678,9 @@
     var a = A.new()
     var Fn = a._Foo
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 7)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 7)
 
-  # Using a private object method funcref from another object method
+  # Using a protected object method funcref from another object method
   lines =<< trim END
     vim9script
     class A
@@ -7812,7 +7812,7 @@
   END
   v9.CheckSourceSuccess(lines)
 
-  # Try using a private class method funcref in a def function
+  # Try using a protected class method funcref in a def function
   lines =<< trim END
     vim9script
     class A
@@ -7824,9 +7824,9 @@
     enddef
     Bar()
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 1)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 1)
 
-  # Try using a private class method funcref at script level
+  # Try using a protected class method funcref at script level
   lines =<< trim END
     vim9script
     class A
@@ -7835,9 +7835,9 @@
     endclass
     var Fn = A._Foo
   END
-  v9.CheckSourceFailure(lines, 'E1366: Cannot access private method: _Foo', 6)
+  v9.CheckSourceFailure(lines, 'E1366: Cannot access protected method: _Foo', 6)
 
-  # Using a private class method funcref from another class method
+  # Using a protected class method funcref from another class method
   lines =<< trim END
     vim9script
     class A
diff --git a/src/version.c b/src/version.c
index 1e45be1..292df39 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2096,
+/**/
     2095,
 /**/
     2094,
diff --git a/src/vim9class.c b/src/vim9class.c
index e9131fe..6149226 100644
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1624,7 +1624,7 @@
 	    if (!is_class && *varname == '_')
 	    {
 		// private variables are not supported in an interface
-		semsg(_(e_private_variable_not_supported_in_interface),
+		semsg(_(e_protected_variable_not_supported_in_interface),
 			varname);
 		break;
 	    }
@@ -1710,7 +1710,7 @@
 		if (!is_class && *name == '_')
 		{
 		    // private variables are not supported in an interface
-		    semsg(_(e_private_method_not_supported_in_interface),
+		    semsg(_(e_protected_method_not_supported_in_interface),
 			    name);
 		    func_clear_free(uf, FALSE);
 		    break;
@@ -2248,7 +2248,7 @@
 
     if (*name == '_')
     {
-	emsg_var_cl_define(e_cannot_access_private_variable_str,
+	emsg_var_cl_define(e_cannot_access_protected_variable_str,
 							m->ocm_name, 0, cl);
 	return FAIL;
     }
@@ -2319,7 +2319,7 @@
     if (ocm == NULL && *fp->uf_name == '_')
     {
 	// Cannot access a private method outside of a class
-	semsg(_(e_cannot_access_private_method_str), fp->uf_name);
+	semsg(_(e_cannot_access_protected_method_str), fp->uf_name);
 	return FAIL;
     }
 
@@ -2437,7 +2437,7 @@
 	    // Private methods are not accessible outside the class
 	    if (*name == '_')
 	    {
-		semsg(_(e_cannot_access_private_method_str), fp->uf_name);
+		semsg(_(e_cannot_access_protected_method_str), fp->uf_name);
 		return FAIL;
 	    }
 
@@ -3078,7 +3078,7 @@
     {
 	// If this is a class method, then give a different error
 	if (*name == '_')
-	    semsg(_(e_cannot_access_private_method_str), method_name);
+	    semsg(_(e_cannot_access_protected_method_str), method_name);
 	else
 	    semsg(_(e_class_method_str_accessible_only_using_class_str),
 		    method_name, cl->class_name);
@@ -3088,7 +3088,7 @@
     {
 	// If this is an object method, then give a different error
 	if (*name == '_')
-	    semsg(_(e_cannot_access_private_method_str), method_name);
+	    semsg(_(e_cannot_access_protected_method_str), method_name);
 	else
 	    semsg(_(e_object_method_str_accessible_only_using_object_str),
 		    method_name, cl->class_name);
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 8a44376..5bd8907 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1617,7 +1617,7 @@
 	     || (!is_object && cctx->ctx_ufunc->uf_class != cl)))
     {
 	char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
-				? e_cannot_access_private_variable_str
+				? e_cannot_access_protected_variable_str
 				: e_variable_is_not_writable_str;
 	emsg_var_cl_define(msg, m->ocm_name, 0, cl);
 	return FALSE;
@@ -2034,8 +2034,8 @@
 		     || (!is_object && cctx->ctx_ufunc->uf_class != cl)))
 	    {
 		char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
-					? e_cannot_access_private_variable_str
-					: e_variable_is_not_writable_str;
+				    ? e_cannot_access_protected_variable_str
+				    : e_variable_is_not_writable_str;
 		emsg_var_cl_define(msg, m->ocm_name, 0, cl);
 		return FAIL;
 	    }
diff --git a/src/vim9execute.c b/src/vim9execute.c
index ff54bcb..997dfa0 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2248,7 +2248,7 @@
 	    {
 		if (*member == '_')
 		{
-		    emsg_var_cl_define(e_cannot_access_private_variable_str,
+		    emsg_var_cl_define(e_cannot_access_protected_variable_str,
 							m->ocm_name, 0, cl);
 		    status = FAIL;
 		}
diff --git a/src/vim9expr.c b/src/vim9expr.c
index feb5df0..a79bb39 100644
--- a/src/vim9expr.c
+++ b/src/vim9expr.c
@@ -403,7 +403,7 @@
 		 || (type->tt_type == VAR_CLASS
 		     && cctx->ctx_ufunc->uf_class != cl)))
 	{
-	    semsg(_(e_cannot_access_private_method_str), name);
+	    semsg(_(e_cannot_access_protected_method_str), name);
 	    return FAIL;
 	}
 
@@ -430,7 +430,7 @@
 	{
 	    if (*name == '_' && !inside_class(cctx, cl))
 	    {
-		emsg_var_cl_define(e_cannot_access_private_variable_str,
+		emsg_var_cl_define(e_cannot_access_protected_variable_str,
 							m->ocm_name, 0, cl);
 		return FAIL;
 	    }
@@ -449,7 +449,7 @@
 	    // Private methods are not accessible outside the class
 	    if (*name == '_' && !inside_class(cctx, cl))
 	    {
-		semsg(_(e_cannot_access_private_method_str), fp->uf_name);
+		semsg(_(e_cannot_access_protected_method_str), fp->uf_name);
 		return FAIL;
 	    }
 	    *arg = name_end;
@@ -472,7 +472,7 @@
 	    // it is defined.
 	    if (*name == '_' && cctx->ctx_ufunc->uf_class != cl)
 	    {
-		emsg_var_cl_define(e_cannot_access_private_variable_str,
+		emsg_var_cl_define(e_cannot_access_protected_variable_str,
 							m->ocm_name, 0, cl);
 		return FAIL;
 	    }
@@ -491,7 +491,7 @@
 	    // Private methods are not accessible outside the class
 	    if (*name == '_' && !inside_class(cctx, cl))
 	    {
-		semsg(_(e_cannot_access_private_method_str), fp->uf_name);
+		semsg(_(e_cannot_access_protected_method_str), fp->uf_name);
 		return FAIL;
 	    }
 	    *arg = name_end;