aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/forwardable.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index 26c5bf7463..fce560db81 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -195,13 +195,23 @@ module Forwardable
accessor = "#{accessor}()"
end
+ unless begin
+ iseq = RubyVM::InstructionSequence
+ .compile("().#{method}", nil, nil, 0, false)
+ rescue SyntaxError
+ else
+ iseq.to_a.dig(-1, 1, 1, :mid) == method.to_sym
+ end
+ method = "__send__ :#{method},"
+ end
+
line_no = __LINE__+1; str = "#{<<-"begin;"}\n#{<<-"end;"}"
begin;
proc do
def #{ali}(*args, &block)
begin
#{accessor}
- end.__send__ :#{method}, *args, &block
+ end.#{method} *args, &block
end
end
end;