summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_symbol.rb6
-rw-r--r--vm_args.c10
2 files changed, 14 insertions, 2 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 6438ec8771..13d7cc9d57 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -191,6 +191,12 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(:hogehoge, _test_to_proc_arg_with_refinements_call(&:hoge))
end
+ def test_to_proc_arg_with_refinements_undefined
+ assert_raise(NoMethodError) do
+ _test_to_proc_arg_with_refinements_call(&:foo)
+ end
+ end
+
private def return_from_proc
Proc.new { return 1 }.tap(&:call)
end
diff --git a/vm_args.c b/vm_args.c
index e1269bbc5f..0b99fdece4 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -853,6 +853,7 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
rb_execution_context_t *ec;
const VALUE symbol = RARRAY_AREF(callback_arg, 0);
const VALUE refinements = RARRAY_AREF(callback_arg, 1);
+ VALUE klass;
if (argc-- < 1) {
rb_raise(rb_eArgError, "no receiver given");
@@ -860,8 +861,13 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
obj = *argv++;
mid = SYM2ID(symbol);
- me = rb_callable_method_entry(CLASS_OF(obj), mid);
- me = rb_resolve_refined_method_callable(refinements, me);
+ for (klass = CLASS_OF(obj); klass; klass = RCLASS_SUPER(klass)) {
+ me = rb_callable_method_entry(klass, mid);
+ if (me) {
+ me = rb_resolve_refined_method_callable(refinements, me);
+ if (me) break;
+ }
+ }
ec = GET_EC();
if (!NIL_P(blockarg)) {