Actions
Bug #8261
closedmodule_function for methods of same name
Description
This affects all versions from 1.8 to 2.0 I have tested.
I'd expect all three examples below to have the same output, but not only does the example with module_function end up with a private instance method, it also has the wrong one.
If the name of the method is different, it behaves as one would expect, this only happens if the methods have the same name.
module A
def a
1
end
module_function
def a
2
end
end
class X
include A
end
module B
def b
1
end
def self.b
2
end
end
class Y
include B
end
module C
def c
1
end
class << self
def c
2
end
end
end
class Z
include C
end
p [A.a, X.new.send(:a)]
=> [2, 2]¶
p [B.b, Y.new.b]
=> [2, 1]¶
p [C.c, Z.new.c]
=> [2, 1]¶
Actions
Like0
Like0Like0