1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

forwardable.rb: full qualify names

* lib/forwardable.rb (def_instance_delegator, def_single_delegator):
  match backtraces against ::Forwardable in case the target class
  is a subclass of BasicObject and does not include Kernel.
  [ruby-core:71176] [Bug #11616]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-10-23 22:29:14 +00:00
parent 92d5da521d
commit 4e1ee809bb
3 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Sat Oct 24 07:29:12 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/forwardable.rb (def_instance_delegator, def_single_delegator):
match backtraces against ::Forwardable in case the target class
is a subclass of BasicObject and does not include Kernel.
[ruby-core:71176] [Bug #11616]
Sat Oct 24 04:10:13 2015 Koichi Sasada <ko1@atdot.net> Sat Oct 24 04:10:13 2015 Koichi Sasada <ko1@atdot.net>
* iseq.c (make_compile_option_value): include frozen_string_literal* * iseq.c (make_compile_option_value): include frozen_string_literal*

View file

@ -182,7 +182,7 @@ module Forwardable
begin begin
#{accessor}.__send__(:#{method}, *args, &block) #{accessor}.__send__(:#{method}, *args, &block)
rescue ::Exception rescue ::Exception
$@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug $@.delete_if{|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
::Kernel::raise ::Kernel::raise
end end
end end
@ -274,7 +274,7 @@ module SingleForwardable
begin begin
#{accessor}.__send__(:#{method}, *args, &block) #{accessor}.__send__(:#{method}, *args, &block)
rescue ::Exception rescue ::Exception
$@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug $@.delete_if{|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
::Kernel::raise ::Kernel::raise
end end
end end

View file

@ -110,6 +110,19 @@ class TestForwardable < Test::Unit::TestCase
assert_not_match(/\/forwardable\.rb/, e.backtrace[0]) assert_not_match(/\/forwardable\.rb/, e.backtrace[0])
end end
class Foo2 < BasicObject
extend ::Forwardable
def_delegator :bar, :baz
end
def test_basicobject_subclass
bug11616 = '[ruby-core:71176] [Bug #11616]'
assert_raise_with_message(NameError, /`bar'/, bug11616) {
Foo2.new.baz
}
end
private private
def forwardable_class(&block) def forwardable_class(&block)