[ruby-dev:47976] [ruby-trunk - Bug #9526] Method#owner returns wrong owner if using prepend.
From:
shugo@...
Date:
2014-02-18 01:30:22 UTC
List:
ruby-dev #47976
Issue #9526 has been updated by Shugo Maeda.
Kaneko Yuichiro wrote:
> In this case, a class or module that defines a method is Blah.
> So I think Blah.new.method(:x).owner should return Blah.
I don't catch your point.
`Blah.new.x(1)` calls MyMod#x, so `Blah.new.method(:x).owner` should return MyMod, shouldn't it?
----------------------------------------
Bug #9526: Method#owner returns wrong owner if using prepend.
https://bugs.ruby-lang.org/issues/9526#change-45224
* Author: Kaneko Yuichiro
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby-2.0.0-p353 [ x86_64 ] & ruby-2.1.0 [ x86_64 ]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
rdoc indicates that Method#owner will return a class or module that defines a method.
http://www.ruby-doc.org/core-2.0/Method.html#method-i-owner
-------------------
module MyMod
def x(y)
super(y*y)
end
end
class Blah
def x(y)
y + 1
end
prepend MyMod
end
Blah.new.method(:x).owner
\# => MyMod
--------------------
In this case, a class or module that defines a method is Blah.
So I think Blah.new.method(:x).owner should return Blah.
--
http://bugs.ruby-lang.org/