Project

General

Profile

Bug #15608 ยป method-inspect-15608.patch

jeremyevans0 (Jeremy Evans), 10/15/2019 02:43 AM

View differences:

proc.c
2817 2817
    str = rb_sprintf("#<% "PRIsVALUE": ", rb_obj_class(method));
2818 2818
    OBJ_INFECT_RAW(str, method);
2819 2819

  
2820
    mklass = data->klass;
2820
    mklass = data->iclass;
2821
    if (!mklass) mklass = data->klass;
2821 2822

  
2822 2823
    if (data->me->def->type == VM_METHOD_TYPE_ALIAS) {
2823 2824
	defined_class = data->me->def->body.alias.original_me->owner;
......
2849 2850
	}
2850 2851
    }
2851 2852
    else {
2853
        mklass = data->klass;
2854
        if (FL_TEST(mklass, FL_SINGLETON)) {
2855
            do {
2856
               mklass = RCLASS_SUPER(mklass);
2857
            } while (RB_TYPE_P(mklass, T_ICLASS));
2858
        }
2852 2859
	rb_str_buf_append(str, rb_inspect(mklass));
2853 2860
	if (defined_class != mklass) {
2854 2861
	    rb_str_catf(str, "(% "PRIsVALUE")", defined_class);
test/ruby/test_method.rb
457 457
    m3 = c3.new.method(:bar)
458 458
    assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo) #{__FILE__}:#{line_no}>", m3.inspect, bug7806)
459 459

  
460
    bug15608 = '[ruby-core:91570] [Bug #15608]'
461
    c4 = Class.new(c)
462
    c4.class_eval { alias bar foo }
463
    o = c4.new
464
    o.singleton_class
465
    m4 = o.method(:bar)
466
    assert_equal("#<Method: #{c4.inspect}(#{c.inspect})#bar(foo) #{__FILE__}:#{line_no}>", m4.inspect, bug15608)
467

  
460 468
    m.taint
461 469
    assert_predicate(m.inspect, :tainted?, "inspect result should be infected")
462 470
  end
463
-