Bug #15608 ยป method-inspect-15608.patch
| proc.c | ||
|---|---|---|
|     str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method)); | ||
|     OBJ_INFECT_RAW(str, method); | ||
|     mklass = data->klass; | ||
|     mklass = data->iclass; | ||
|     if (!mklass) mklass = data->klass; | ||
|     if (data->me->def->type == VM_METHOD_TYPE_ALIAS) { | ||
| 	defined_class = data->me->def->body.alias.original_me->owner; | ||
| ... | ... | |
| 	} | ||
|     } | ||
|     else { | ||
|         mklass = data->klass; | ||
|         if (FL_TEST(mklass, FL_SINGLETON)) { | ||
|             do { | ||
|                mklass = RCLASS_SUPER(mklass); | ||
|             } while (RB_TYPE_P(mklass, T_ICLASS)); | ||
|         } | ||
| 	rb_str_buf_append(str, rb_inspect(mklass)); | ||
| 	if (defined_class != mklass) { | ||
| 	    rb_str_catf(str, "(% "PRIsVALUE")", defined_class); | ||
| test/ruby/test_method.rb | ||
|---|---|---|
|     m3 = c3.new.method(:bar) | ||
|     assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo) #{__FILE__}:#{line_no}>", m3.inspect, bug7806) | ||
|     bug15608 = '[ruby-core:91570] [Bug #15608]' | ||
|     c4 = Class.new(c) | ||
|     c4.class_eval { alias bar foo } | ||
|     o = c4.new | ||
|     o.singleton_class | ||
|     m4 = o.method(:bar) | ||
|     assert_equal("#<Method: #{c4.inspect}(#{c.inspect})#bar(foo) #{__FILE__}:#{line_no}>", m4.inspect, bug15608) | ||
|     m.taint | ||
|     assert_predicate(m.inspect, :tainted?, "inspect result should be infected") | ||
|   end | ||