From edeb0319f7a95dfe3f9b895bcf32371dd8514726 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 4 Nov 2024 14:42:47 -0800 Subject: merge revision(s) 6118e8a47394409b53164b60e79fadf348b97db3: [Backport #20716] Fix method caching bug when including/prepend module A that prepends module B Fix by always adding the generated iclass to the subclasses list, otherwise the method cache for the iclass is not cleared when the method in the module is overwritten. Fixes [Bug #20716] --- test/ruby/test_super.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index ce78e66c52..acc59c1520 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -617,6 +617,35 @@ class TestSuper < Test::Unit::TestCase } end + def test_super_with_included_prepended_module_method_caching_bug_20716 + a = Module.new do + def test(*args) + super + end + end + + b = Module.new do + def test(a) + a + end + end + + c = Class.new + + b.prepend(a) + c.include(b) + + assert_equal(1, c.new.test(1)) + + b.class_eval do + def test + :test + end + end + + assert_equal(:test, c.new.test) + end + class TestFor_super_with_modified_rest_parameter_base def foo *args args -- cgit v1.2.3