summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_refinement.rb26
-rw-r--r--vm_insnhelper.c2
2 files changed, 27 insertions, 1 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 5fba208fb7..2386b54dec 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2010,6 +2010,32 @@ class TestRefinement < Test::Unit::TestCase
assert_equal(:foo, ToSymbol.new("foo").symbol)
end
+ def test_unused_refinement_for_module
+ bug14068 = '[ruby-core:83613] [Bug #14068]'
+ assert_in_out_err([], <<-INPUT, ["M1#foo"], [], bug14068)
+ module M1
+ def foo
+ puts "M1#foo"
+ end
+ end
+
+ module M2
+ end
+
+ module UnusedRefinement
+ refine(M2) do
+ def foo
+ puts "M2#foo"
+ end
+ end
+ end
+
+ include M1
+ include M2
+ foo()
+ INPUT
+ end
+
private
def eval_using(mod, s)
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 3c08a74f09..9a2f3cb2d9 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -2314,7 +2314,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
cc->me = refined_method_callable_without_refinement(cc->me);
}
else {
- VALUE klass = RCLASS_SUPER(cc->me->owner);
+ VALUE klass = RCLASS_SUPER(cc->me->defined_class);
cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL;
}
return vm_call_method(ec, cfp, calling, ci, cc);