Project

General

Profile

Actions

Backport #1151

closed

Aliased methods change super logic when retrieved with Object#method

Added by headius (Charles Nutter) about 15 years ago. Updated over 10 years ago.


Description

=begin
This is a peculiar case I don't believe I've reported before. It seems that "method" can change the super behavior of an alias:

Test weird likely-a-bug where method() will repurpose where super goes to

class Foo222
def a; 'a'; end
def b; 'b'; end
end

class Bar222 < Foo222
def a; super; end
alias b a
end

puts('a' == Bar222.new.b) # true
puts('a' == Bar222.new.method(:b).call) # false

Ruby 1.9 behaves as you would expect, calling the "a" super method in both cases. We changed our behavior in JRuby 1.1.2 to match Ruby 1.8.6, but I still believe this is a bug. The JRuby bug report is here: http://jira.codehaus.org/browse/JRUBY-1192 and I reported it to ruby-core here: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/11600 and a patch was proposed here: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/11603. Since it behaves as I expect in 1.9, I assume the 1.8.x behavior is incorrect.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0