summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-13 06:13:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-13 06:13:08 +0000
commit99126a4c88d3ddb9ea76edf948307c7bfa0fe971 (patch)
tree1c472e98892cf684c6a7ed05a3e140f38eb2a07c /class.c
parentbe909b5e95e5ba56eadb42e6dbc9102c1188ae48 (diff)
class.c: from the origin class
* class.c (rb_obj_singleton_methods): collect methods from the origin class. [ruby-core:53207] [Bug #8044] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/class.c b/class.c
index 36b7f0d..c6af2c8 100644
--- a/class.c
+++ b/class.c
@@ -1228,8 +1228,8 @@ rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
VALUE
rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
{
- VALUE recur, ary, klass;
- st_table *list;
+ VALUE recur, ary, klass, origin;
+ st_table *list, *mtbl;
if (argc == 0) {
recur = Qtrue;
@@ -1238,16 +1238,17 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
rb_scan_args(argc, argv, "01", &recur);
}
klass = CLASS_OF(obj);
+ origin = RCLASS_ORIGIN(klass);
list = st_init_numtable();
if (klass && FL_TEST(klass, FL_SINGLETON)) {
- if (RCLASS_M_TBL(klass))
- st_foreach(RCLASS_M_TBL(klass), method_entry_i, (st_data_t)list);
+ if ((mtbl = RCLASS_M_TBL(origin)) != 0)
+ st_foreach(mtbl, method_entry_i, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
if (RTEST(recur)) {
while (klass && (FL_TEST(klass, FL_SINGLETON) || RB_TYPE_P(klass, T_ICLASS))) {
- if (RCLASS_M_TBL(klass))
- st_foreach(RCLASS_M_TBL(klass), method_entry_i, (st_data_t)list);
+ if (klass != origin && (mtbl = RCLASS_M_TBL(klass)) != 0)
+ st_foreach(mtbl, method_entry_i, (st_data_t)list);
klass = RCLASS_SUPER(klass);
}
}