Skip to content

Commit

Permalink
Clear all refined CCs on reopening refinement mod
Browse files Browse the repository at this point in the history
In cfd7729 we started using inline
caches for refinements. However, we weren't clearing inline caches when
defined on a reopened refinement module.

Fixes [Bug #20246]
  • Loading branch information
jhawthorn committed Mar 7, 2024
1 parent 4a4e5dd commit 18ee7c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/ruby/test_refinement.rb
Expand Up @@ -1606,18 +1606,35 @@ def m
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

Expand Down
1 change: 1 addition & 0 deletions vm_method.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit 18ee7c9

Please sign in to comment.