patch 9.1.1105: Vim9: no support for protected new() method

Problem:  Vim9: no support for protected new() method
Solution: support the protected "_new()" object method
          (Yegappan Lakshmanan)

closes: #16604

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2025-02-11 22:07:05 +01:00
committed by Christian Brabandt
parent f0ed0e6f63
commit 7e89800988
5 changed files with 48 additions and 4 deletions

View File

@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2025 Feb 08
*version9.txt* For Vim version 9.1. Last change: 2025 Feb 11
VIM REFERENCE MANUAL by Bram Moolenaar
@ -41551,6 +41551,8 @@ Add support for internal builtin functions with vim9 objects, see
Enum support for Vim9 script |:enum|
Support for protected _new() method
*new-other-9.2*
Other new features ~
------------------

View File

@ -1,4 +1,4 @@
*vim9class.txt* For Vim version 9.1. Last change: 2024 Dec 29
*vim9class.txt* For Vim version 9.1. Last change: 2025 Feb 11
VIM REFERENCE MANUAL by Bram Moolenaar
@ -272,6 +272,9 @@ no need to call "super()" or "new()" on the parent.
When defining the new() method the return type should not be specified. It
always returns an object of the class.
The new() method can be made a protected method by using "_new()". This can
be used to support the singleton design pattern.
*E1386*
When invoking an object method, the method name should be preceded by the
object variable name. An object method cannot be invoked using the class