diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-25 07:57:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-06-25 07:57:42 +0000 |
commit | e6f1e3f49db1694116d286666ccaa026cad61f3e (patch) | |
tree | f65585b755a1ab98bd697e3c7f23f4ba48f55ab9 /proc.c | |
parent | 0f0f0f4441e1e8845bf37f6eee712d9f4f73b908 (diff) |
method transplanting
* proc.c (rb_mod_define_method): allow method transplanting from a
module to either class or module. [ruby-core:34267][Feature #4254]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1360,7 +1360,8 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) if (rb_obj_is_method(body)) { struct METHOD *method = (struct METHOD *)DATA_PTR(body); VALUE rclass = method->rclass; - if (rclass != mod && !RTEST(rb_class_inherited_p(mod, rclass))) { + if (rclass != mod && !RB_TYPE_P(rclass, T_MODULE) && + !RTEST(rb_class_inherited_p(mod, rclass))) { if (FL_TEST(rclass, FL_SINGLETON)) { rb_raise(rb_eTypeError, "can't bind singleton method to a different class"); |