From 1e7cf7b2bc1f9b356b2e980e1e18548618da6363 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 10 Oct 2025 16:32:43 -0700 Subject: 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] --- test/ruby/test_refinement.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/ruby') 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 -- cgit v1.2.3