Project

General

Profile

Bug #11188 ยป method-inspect-chain-alias-11188.patch

jeremyevans0 (Jeremy Evans), 08/12/2019 10:21 PM

View differences:

test/ruby/test_alias.rb
35 35
    end
36 36
  end
37 37

  
38
  class Alias4 < Alias0
39
    alias foo1 foo
40
    alias foo2 foo1
41
    alias foo3 foo2
42
  end
43

  
38 44
  def test_alias
39 45
    x = Alias2.new
40 46
    assert_equal "foo", x.bar
......
47 53
    assert_raise(NoMethodError) { x.quux }
48 54
  end
49 55

  
56
  def test_alias_inspect
57
    o = Alias4.new
58
    assert_equal("TestAlias::Alias4(TestAlias::Alias0)#foo", o.method(:foo).inspect.split[1])
59
    assert_equal("TestAlias::Alias4(TestAlias::Alias0)#foo1(foo)", o.method(:foo1).inspect.split[1])
60
    assert_equal("TestAlias::Alias4(TestAlias::Alias0)#foo2(foo)", o.method(:foo2).inspect.split[1])
61
    assert_equal("TestAlias::Alias4(TestAlias::Alias0)#foo3(foo)", o.method(:foo3).inspect.split[1])
62
  end
63

  
50 64
  class C
51 65
    def m
52 66
      $SAFE
vm_method.c
1603 1603

  
1604 1604
	alias_me = method_entry_set(target_klass, alias_name, orig_me, visi, orig_me->owner);
1605 1605
	RB_OBJ_WRITE(alias_me, &alias_me->owner, target_klass);
1606
	RB_OBJ_WRITE(alias_me, &alias_me->defined_class, defined_class);
1606
        if (orig_me->owner == defined_class &&
1607
            orig_me->owner != orig_me->defined_class &&
1608
            alias_me->owner == alias_me->defined_class) {
1609
            defined_class = orig_me->defined_class;
1610
        }
1611

  
1612
        RB_OBJ_WRITE(alias_me, &alias_me->defined_class, defined_class);
1607 1613
    }
1608 1614
}
1609 1615

  
1610
-