mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_insnhelper.c: revive r44455 for bound module method
* vm_insnhelper.c (vm_search_super_method): when super called in a bound UnboundMethod generated from a module, no superclass is found since the current defined class is the module, then call method_missing in that case. [ruby-core:59619] [Bug #9377] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fe46b2d5f0
commit
5c0d17c9a2
3 changed files with 26 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Jan 8 22:53:16 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_search_super_method): when super called in a
|
||||||
|
bound UnboundMethod generated from a module, no superclass is
|
||||||
|
found since the current defined class is the module, then call
|
||||||
|
method_missing in that case. [ruby-core:59619] [Bug #9377]
|
||||||
|
|
||||||
Wed Jan 8 15:55:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Jan 8 15:55:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (rb_objid_hash): return hash value from object ID with a
|
* hash.c (rb_objid_hash): return hash value from object ID with a
|
||||||
|
|
|
@ -440,4 +440,17 @@ class TestSuper < Test::Unit::TestCase
|
||||||
assert_equal(:ok, o.method(:foo).call, bug9315)
|
assert_equal(:ok, o.method(:foo).call, bug9315)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_missing_super_in_module_unbound_method
|
||||||
|
bug9377 = '[ruby-core:59619] [Bug #9377]'
|
||||||
|
|
||||||
|
a = Module.new do
|
||||||
|
def foo; super end
|
||||||
|
end
|
||||||
|
|
||||||
|
m = a.instance_method(:foo).bind(Object.new.extend(a))
|
||||||
|
assert_raise(NoMethodError, bug9377) do
|
||||||
|
m.call
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2024,6 +2024,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
|
||||||
" by define_method() is not supported."
|
" by define_method() is not supported."
|
||||||
" Specify all arguments explicitly.");
|
" Specify all arguments explicitly.");
|
||||||
}
|
}
|
||||||
|
if (!ci->klass) {
|
||||||
|
/* bound instance method of module */
|
||||||
|
ci->aux.missing_reason = NOEX_SUPER;
|
||||||
|
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: use inline cache */
|
/* TODO: use inline cache */
|
||||||
ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
|
ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);
|
||||||
|
|
Loading…
Reference in a new issue