summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2021-04-02 12:26:56 +0900
committerNARUSE, Yui <naruse@airemix.jp>2021-04-02 12:26:56 +0900
commitd1cec0bca588266b9af1d55e592016c45ee68fbb (patch)
tree031006f474153083b9f7ebdaaddf0b336959c795 /test/ruby
parentd3779ab3b8c1cc2b47d8072ec0cf83b52ff9c97c (diff)
merge revision(s) 58660e943488778563b9e41005a601e9660ce21f: [Backport #17519]
Skip refined method when exporting methods with changed visibility Previously, attempting to change the visibility of a method in a singleton class for a class/module that is prepended to and refined would raise a NoMethodError. Fixes [Bug #17519] --- test/ruby/test_module.rb | 23 +++++++++++++++++++++++ vm_method.c | 14 +++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_module.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 43f0c51753..254dc51b9b 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -2237,6 +2237,29 @@ class TestModule < Test::Unit::TestCase
assert_equal(0, 1 / 2)
end
+ def test_visibility_after_refine_and_visibility_change
+ m = Module.new
+ c = Class.new do
+ def x; :x end
+ end
+ c.prepend(m)
+ Module.new do
+ refine c do
+ def x; :y end
+ end
+ end
+
+ o1 = c.new
+ o2 = c.new
+ assert_equal(:x, o1.public_send(:x))
+ assert_equal(:x, o2.public_send(:x))
+ o1.singleton_class.send(:private, :x)
+ o2.singleton_class.send(:public, :x)
+
+ assert_raise(NoMethodError) { o1.public_send(:x) }
+ assert_equal(:x, o2.public_send(:x))
+ end
+
def test_prepend_visibility
bug8005 = '[ruby-core:53106] [Bug #8005]'
c = Class.new do