From 69dc2ce6640ac71b24e6e4a2b7bb42f058cfa809 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 22 Apr 2016 15:24:35 +0000 Subject: merge revision(s) 53382,53511,53512: [Backport #11916] fix commit miss * test/test_forwardable.rb: add tests for r53381. * lib/forwardable.rb: Convert given accessors to String. r53381 changed to accept only Symbol or String for accessors, but there are several rubygems that pass classes (e.g. Array, Hash, ...) as accessors. Prior r53381, it was accepted because Class#to_s returns its class name. After r53381 given accessors are checked with define_method, but it accepts only Symbol or String, otherwise raises TypeError. def_delegator Foo, :some_method This change is to revert unwanted incompatibility. But this behavior may change in the future. This change is to revert unexpected incompatibility. But this behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/forwardable.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/forwardable.rb b/lib/forwardable.rb index f27437af82..e20f5e3a31 100644 --- a/lib/forwardable.rb +++ b/lib/forwardable.rb @@ -178,6 +178,7 @@ module Forwardable # q.push 23 #=> NoMethodError # def def_instance_delegator(accessor, method, ali = method) + accessor = accessor.to_s if method_defined?(accessor) || private_method_defined?(accessor) accessor = "#{accessor}()" end @@ -274,6 +275,7 @@ module SingleForwardable # the method of the same name in _accessor_). If _new_name_ is # provided, it is used as the name for the delegate method. def def_single_delegator(accessor, method, ali = method) + accessor = accessor.to_s if method_defined?(accessor) || private_method_defined?(accessor) accessor = "#{accessor}()" end -- cgit v1.2.3