Clear all refined CCs on reopening refinement mod

In cfd7729ce7 we started using inline
caches for refinements. However, we weren't clearing inline caches when
defined on a reopened refinement module.

Fixes [Bug #20246]
This commit is contained in:
John Hawthorn 2024-02-19 18:53:13 -08:00
Родитель 4a4e5dd9c9
Коммит 18ee7c9a10
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -1606,18 +1606,35 @@ class TestRefinement < Test::Unit::TestCase
end
using R
def m
C.new.m
end
assert_equal(:foo, C.new.m)
assert_equal(:foo, m)
module R
refine C do
assert_equal(:foo, C.new.m)
assert_equal(:foo, m)
alias m m
assert_equal(:foo, C.new.m)
assert_equal(:foo, m)
def m
:bar
end
assert_equal(:bar, C.new.m, "[ruby-core:71423] [Bug #11672]")
assert_equal(:bar, m, "[Bug #20285]")
end
end
assert_equal(:bar, C.new.m, "[ruby-core:71423] [Bug #11672]")
assert_equal(:bar, m, "[Bug #20285]")
end;
end

Просмотреть файл

@ -301,6 +301,7 @@ rb_clear_method_cache(VALUE klass_or_module, ID mid)
VALUE refined_class = rb_refinement_module_get_refined_class(module);
rb_clear_method_cache(refined_class, mid);
rb_class_foreach_subclass(refined_class, clear_iclass_method_cache_by_id_for_refinements, mid);
rb_clear_all_refinement_method_cache();
}
rb_class_foreach_subclass(module, clear_iclass_method_cache_by_id, mid);
}