Allow calling a private method with self.

This makes it consistent with calling private attribute assignment
methods, which currently is allowed (e.g. `self.value =`).

Calling a private method in this way can be useful when trying to
assign the return value to a local variable with the same name.

[Feature #11297] [Feature #16123]
This commit is contained in:
Dylan Thacker-Smith 2019-07-02 15:06:54 +01:00 committed by Nobuyoshi Nakada
parent 17a1366399
commit 7fbd2f7cc2
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
Notes: git 2019-09-20 03:25:07 +09:00
5 changed files with 9 additions and 4 deletions

View file

@ -2479,7 +2479,8 @@ class TestModule < Test::Unit::TestCase
assert_include(methods, :#{method}, ":#{method} should be private")
assert_raise_with_message(NoMethodError, "private method `#{method}' called for main:Object") {
self.#{method}
recv = self
recv.#{method}
}
}
end