diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-22 20:37:20 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-22 20:37:20 +0000 |
commit | a4c105c337a22c79b15560d495d218ff966fdeca (patch) | |
tree | 57b80b8420cb617674340ccb172e16e950792efb /eval.c | |
parent | d67008b46dc8242161114fd3615e371cdedff31b (diff) |
* eval.c (umethod_bind): Fix bug that disallowed methods from singleton classes to be used for UnboundMethod#bind and Module#define_method, even when that singleton class was of the right kind_of [ruby-core:25632]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9809,9 +9809,6 @@ umethod_bind(method, recv) Data_Get_Struct(method, struct METHOD, data); if (data->rklass != rklass) { - if (FL_TEST(data->rklass, FL_SINGLETON)) { - rb_raise(rb_eTypeError, "singleton method bound for a different object"); - } if (TYPE(data->rklass) == T_MODULE) { st_table *m_tbl = RCLASS(data->rklass)->m_tbl; while (RCLASS(rklass)->m_tbl != m_tbl) { @@ -9820,9 +9817,13 @@ umethod_bind(method, recv) } } else if (!rb_obj_is_kind_of(recv, data->rklass)) { - not_instace: - rb_raise(rb_eTypeError, "bind argument must be an instance of %s", - rb_class2name(data->rklass)); + if (FL_TEST(data->rklass, FL_SINGLETON)) { + rb_raise(rb_eTypeError, "singleton method bound for a different object"); + } else { + not_instace: + rb_raise(rb_eTypeError, "bind argument must be an instance of %s", + rb_class2name(data->rklass)); + } } } |