Bug #6660 » prepend_instance_methods_false.patch
| class.c | ||
|---|---|---|
| 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) { | ||
| ... | ... | |
| 	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; | ||
|     } | ||
| test/ruby/test_module.rb | ||
|---|---|---|
|       end | ||
|     end | ||
|   end | ||
|   def test_prepend_instance_methods_fale | ||
|     assert_equal([:m1], Class.new{ prepend Module.new; def m1; end }.instance_methods(false)) | ||
|     assert_equal([:m1], Class.new(Class.new{def m2;end}){ prepend Module.new; def m1; end }.instance_methods(false)) | ||
|   end | ||
| end | ||