Actions
Bug #11188
closedMethod#inspect for chaining alias methods
Description
The following script prints strange results (at least for me).
class C0
def foo
end
end
class C1 < C0
alias foo1 foo
alias foo2 foo1
alias foo3 foo2
end
p C1.new.method(:foo)
p C1.new.method(:foo1)
p C1.new.method(:foo2)
p C1.new.method(:foo3)
Result:
#<Method: C1(C0)#foo>
#<Method: C1(C0)#foo1(foo)>
#<Method: C1#foo2(foo)>
#<Method: C1#foo3(foo)>
I believe 3rd and 4th results should be:
#<Method: C1(C0)#foo2(foo)>
#<Method: C1(C0)#foo3(foo)>
How about it?
Files
Updated by jeremyevans0 (Jeremy Evans) over 4 years ago
I agree with ko1's opinion. Attached is a patch that implements his proposal.
Note that this change cannot be made in method_inspect
, because at that time, the necessary information has already been lost. To implement ko1's proposal, changes to rb_alias
are required, so that the defined_class
in the alias chain methods (foo2
and foo3
) is set correctly to C0
.
Updated by jeremyevans0 (Jeremy Evans) almost 4 years ago
- Status changed from Open to Closed
This patch was merged in adecd43197d5ea2a62a618a5c9be653bcf009c62.
Updated by Eregon (Benoit Daloze) almost 4 years ago
Nice, in fact this was already the behavior in TruffleRuby and JRuby.
Actions
Like0
Like0Like0Like0