diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 13:41:03 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-05 13:41:03 +0000 |
commit | e7a2c4251e98cd515d861facbba2fa86983dfb89 (patch) | |
tree | 5453a0f1c25ef906b434cb3d9d1a1ed0ca7b5e01 | |
parent | 1b05b4f4abbb7352f04e718ba7a4c62859f91a92 (diff) |
merge revision(s) 44527,44552,44553:
* 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]
* vm_insnhelper.c (vm_search_super_method): allow bound method from a
module, yet another method transplanting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 13 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | vm_insnhelper.c | 9 |
4 files changed, 34 insertions, 2 deletions
@@ -1,3 +1,15 @@ +Wed Feb 5 22:28:41 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_insnhelper.c (vm_search_super_method): allow bound method from a + module, yet another method transplanting. + +Wed Feb 5 22:28:41 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 Feb 5 21:57:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * ext/socket/socket.c (rsock_syserr_fail_host_port): add errno diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index c5f724ebb8..82d6e19ec4 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -440,4 +440,17 @@ class TestSuper < Test::Unit::TestCase assert_equal(:ok, o.method(:foo).call, bug9315) 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) + assert_raise(NoMethodError, bug9377) do + m.call + end + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-05" -#define RUBY_PATCHLEVEL 20 +#define RUBY_PATCHLEVEL 21 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 diff --git a/vm_insnhelper.c b/vm_insnhelper.c index c8cbaa07bf..edf4e46652 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2004,7 +2004,8 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf current_defined_class = RCLASS_REFINED_CLASS(current_defined_class); } - if (!FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && + if (BUILTIN_TYPE(current_defined_class) != T_MODULE && + !FL_TEST(current_defined_class, RMODULE_INCLUDED_INTO_REFINEMENT) && !rb_obj_is_kind_of(ci->recv, current_defined_class)) { VALUE m = RB_TYPE_P(current_defined_class, T_ICLASS) ? RBASIC(current_defined_class)->klass : current_defined_class; @@ -2024,6 +2025,12 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf " by define_method() is not supported." " 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 */ ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class); |