mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
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:
parent
17a1366399
commit
7fbd2f7cc2
Notes:
git
2019-09-20 03:25:07 +09:00
5 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue