[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-core
Subject: [ruby-core:89663] [Ruby trunk Bug#15274] Reflection does not report methods defined only in refineme
From: email () pitr ! ch
Date: 2018-10-31 19:40:59
Message-ID: redmine.issue-15274.20181031194058.e3d687cfbba8979c () ruby-lang ! org
[Download RAW message or body]
Issue #15274 has been reported by pitr.ch (Petr Chalupa).
----------------------------------------
Bug #15274: Reflection does not report methods defined only in refinements
https://bugs.ruby-lang.org/issues/15274
* Author: pitr.ch (Petr Chalupa)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
class C
end
module M
refine C do
def foo
puts "C#foo in M"
end
end
end
using M
c = C.new
c.foo # prints "C#foo in M"
c.send :foo
p c.respond_to? :foo
p c.methods.include?(:foo)
p C.instance_methods.include?(:foo)
p((c.method(:foo) rescue false))
__END__
Prints:
C#foo in M
C#foo in M
false
false
false
false
~~~
When the refinement M is used I think it would be less surprising if reflection \
methods (respond_to?, methods, method, instance_methods) report available methods \
including the ones coming from refinement.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic