mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* class.c (class_instance_method_list): consider prepended Class/Module
when recur != 0. [ruby-dev:45863] [Bug #6660] * test/ruby/test_module.rb (test_prepend_instance_methods_false): add a test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a4932b54b5
commit
912df4b615
3 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
Thu Jun 28 09:27:09 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||
|
||||
* class.c (class_instance_method_list): consider prepended Class/Module
|
||||
when recur != 0. [ruby-dev:45863] [Bug #6660]
|
||||
|
||||
* test/ruby/test_module.rb (test_prepend_instance_methods_false): add
|
||||
a test for it.
|
||||
|
||||
|
||||
Thu Jun 28 06:12:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* class.c (rb_mod_ancestors): fix ancestors order.
|
||||
|
|
9
class.c
9
class.c
|
@ -938,7 +938,7 @@ static VALUE
|
|||
class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func) (st_data_t, st_data_t, st_data_t))
|
||||
{
|
||||
VALUE ary;
|
||||
int recur;
|
||||
int recur, prepended = 0;
|
||||
st_table *list;
|
||||
|
||||
if (argc == 0) {
|
||||
|
@ -950,10 +950,15 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func
|
|||
recur = RTEST(r);
|
||||
}
|
||||
|
||||
if (!recur && RCLASS_ORIGIN(mod) != mod) {
|
||||
mod = RCLASS_ORIGIN(mod);
|
||||
prepended = 1;
|
||||
}
|
||||
|
||||
list = st_init_numtable();
|
||||
for (; mod; mod = RCLASS_SUPER(mod)) {
|
||||
if (RCLASS_M_TBL(mod)) st_foreach(RCLASS_M_TBL(mod), method_entry_i, (st_data_t)list);
|
||||
if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
|
||||
if (BUILTIN_TYPE(mod) == T_ICLASS && !prepended) continue;
|
||||
if (obj && FL_TEST(mod, FL_SINGLETON)) continue;
|
||||
if (!recur) break;
|
||||
}
|
||||
|
|
|
@ -1327,4 +1327,10 @@ class TestModule < Test::Unit::TestCase
|
|||
class_eval(&block) if block
|
||||
end
|
||||
end
|
||||
|
||||
def test_prepend_instance_methods_false
|
||||
bug6660 = '[ruby-dev:45863]'
|
||||
assert_equal([:m1], Class.new{ prepend Module.new; def m1; end }.instance_methods(false), bug6660)
|
||||
assert_equal([:m1], Class.new(Class.new{def m2;end}){ prepend Module.new; def m1; end }.instance_methods(false), bug6660)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue