summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2025-10-10 16:32:43 -0700
committerJeremy Evans <code@jeremyevans.net>2025-12-10 06:19:52 +0900
commit1e7cf7b2bc1f9b356b2e980e1e18548618da6363 (patch)
tree5cf07a5945150ed91e70b8955e8813c53561dc2d /test/ruby
parent6409715212d22699bd2751a363b050a5d8b94b83 (diff)
Fix refinement modification of method visibility in superclass
Previously, this didn't work correctly, resulting in a SystemStackError. This fixes the issue by finding the related superclass method entry, and updating the orig_me in the refinement method to point to the superclass method. Fixes [Bug #21446]
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_refinement.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index bdc6667b8e..209e55294b 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1933,6 +1933,29 @@ class TestRefinement < Test::Unit::TestCase
end;
end
+ def test_public_in_refine_for_method_in_superclass
+ assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
+ begin;
+ bug21446 = '[ruby-core:122558] [Bug #21446]'
+
+ class CowSuper
+ private
+ def moo() "Moo"; end
+ end
+ class Cow < CowSuper
+ end
+
+ module PublicCows
+ refine(Cow) {
+ public :moo
+ }
+ end
+
+ using PublicCows
+ assert_equal("Moo", Cow.new.moo, bug21446)
+ end;
+ end
+
module SuperToModule
class Parent
end