Issue #7842 has been updated by marcandre (Marc-Andre Lafortune).


nobu (Nobuyoshi Nakada) wrote:
> Rather I expect [B, A] in this case.

You do?

There would be no way to safely monkey patch this method without using Prepend! So any 1.9.x library that uses monkey patching like alias_method_chain could be incompatible with prepended classes!

I expect:
  B.instance_method(:m) == B.instance_method(:m2) # => true in rc2, false in trunk, should be true
  B.new.m2 # => [P, B, A], since they are aliases appart from their name

Here is another bug (even more clear) that might be related:
  B.instance_method(:m).owner # => P in rc2 (ok), B in trunk (not ok)
  B.instance_method(:m2).owner # => #<B:0x0000010384b418>, should be P

I wish I had time to look at it further.
----------------------------------------
Bug #7842: An alias of a "prepend"ed method skips the original method when calling super
https://bugs.ruby-lang.org/issues/7842#change-36292

Author: mame (Yusuke Endoh)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: next minor
ruby -v: ruby 2.0.0dev (2013-02-13 trunk 39225) [x86_64-linux]


Hello,

  module P
    def m; puts "P"; super; end
  end
  class A
    def m; puts "A"; end
  end
  class B < A
    def m; puts "B"; end
    prepend P
    alias m2 m
  end
  B.new.m2
    #=> expected: P, B, A
    #=> actual:   P, A

Is this intentional?
It looks weird to me that calling super of P#m (as m2) skips A#m.

-- 
Yusuke Endoh <mame / tsg.ne.jp>


-- 
http://bugs.ruby-lang.org/