summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorÉtienne Barrié <etienne.barrie@gmail.com>2016-08-30 13:29:07 -0400
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-13 11:29:42 +0900
commit2dc613815d2c4a69bfbcbf78d1b99aa52fbabf60 (patch)
tree38d501e176f0772c5766284b284d4a9c25d1f3d9 /lib
parent24964fff92cd89925d2169ad97a357a5bc57e3e1 (diff)
delegate.rb: don't look for methods on Kernel
Instead, look for instance methods of Kernel. Otherwise, instance methods of Module (which are methods of Kernel itself) are mistakenly believed to exist, and it fails when calling Kernel.instance_method(). Closes: https://github.com/ruby/ruby/pull/1422
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 85c1eb4e4e..9f8ef9d5ad 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -81,7 +81,7 @@ class Delegator < BasicObject
if r && target.respond_to?(m)
target.__send__(m, *args, &block)
- elsif ::Kernel.respond_to?(m, true)
+ elsif ::Kernel.method_defined?(m) || ::Kernel.private_method_defined?(m)
::Kernel.instance_method(m).bind(self).(*args, &block)
else
super(m, *args, &block)