diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-29 12:42:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-29 12:42:42 +0000 |
commit | 3449d4fa2d2ac0655eb55a770aa10fc829660760 (patch) | |
tree | 8b10337a18e345187a1bbaf26c200d86d5b197fb /test/ruby | |
parent | 97c977debf8592de87df808872515715040c6aa6 (diff) | |
download | ruby-3449d4fa2d2ac0655eb55a770aa10fc829660760.tar.gz |
visibility of inherited method
* vm_insnhelper.c (vm_call_method_each_type): honor the original
visibility of inherited methods when a refinement is defined but
not activated. [ruby-core:82209] [Bug #13776]
Author: Mon_Ouie (Mon ouïe) <mon.ouie@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_refinement.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 82bdb49659..c7df789306 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1900,6 +1900,50 @@ class TestRefinement < Test::Unit::TestCase end end + class ParentDefiningPrivateMethod + private + def some_inherited_method + end + end + + module MixinDefiningPrivateMethod + private + def some_included_method + end + end + + class SomeChildClassToRefine < ParentDefiningPrivateMethod + include MixinDefiningPrivateMethod + + private + def some_method + end + end + + def test_refine_inherited_method_with_visibility_changes + Module.new do + refine(SomeChildClassToRefine) do + def some_inherited_method; end + def some_included_method; end + def some_method; end + end + end + + obj = SomeChildClassToRefine.new + + assert_raise_with_message(NoMethodError, /private/) do + obj.some_inherited_method + end + + assert_raise_with_message(NoMethodError, /private/) do + obj.some_included_method + end + + assert_raise_with_message(NoMethodError, /private/) do + obj.some_method + end + end + private def eval_using(mod, s) |