I never thought about having such a “method visible classed scoped variable”, but it makes total sense. I also have quite a few places with properties only to be used in a single method that are an internal implementation detail.
… method visible classed scoped variable …
Perfect description for the feature - thanks.
There is a grey area where a variable is only used in one method, but the functionality is too small or too tightly bound to the rest of the class for the variable and method to be split into a separate class.
Allowing a nested scope for variables might make sense. I have encountered several cases where this would help to tidy/clarify/defend the code.
What you can do is to create an optin annotation (I’m not sure that private visibility works, but try it if it does), put that on the function and private property. Then you can just check that the annotation isn’t used in other places and you have your restricted access where accidental use/modification is much harder.