summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_refinement.rb33
-rw-r--r--vm_method.c4
2 files changed, 36 insertions, 1 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 51231bd56c..dd443b7945 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2405,6 +2405,39 @@ class TestRefinement < Test::Unit::TestCase
end
end
+ def test_refine_frozen_class
+ singleton_class.instance_variable_set(:@x, self)
+ class << self
+ c = Class.new do
+ def foo
+ :cfoo
+ end
+ end
+ foo = Module.new do
+ refine c do
+ def foo
+ :rfoo
+ end
+ end
+ end
+ using foo
+ @x.assert_equal(:rfoo, c.new.foo)
+ c.freeze
+ foo.module_eval do
+ refine c do
+ def foo
+ :rfoo2
+ end
+ def bar
+ :rbar
+ end
+ end
+ end
+ @x.assert_equal(:rfoo2, c.new.foo)
+ @x.assert_equal(:rbar, c.new.bar, '[ruby-core:71391] [Bug #11669]')
+ end
+ end
+
private
def eval_using(mod, s)
diff --git a/vm_method.c b/vm_method.c
index f1b71a181c..2b2e28e10c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -714,7 +714,9 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil
}
}
- rb_class_modify_check(klass);
+ if (type != VM_METHOD_TYPE_REFINED) {
+ rb_class_modify_check(klass);
+ }
if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
VALUE refined_class = rb_refinement_module_get_refined_class(klass);