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:
parent
92d5da521d
commit
4e1ee809bb
3 changed files with 22 additions and 2 deletions
|
@ -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>
|
||||
|
||||
* iseq.c (make_compile_option_value): include frozen_string_literal*
|
||||
|
|
|
@ -182,7 +182,7 @@ module Forwardable
|
|||
begin
|
||||
#{accessor}.__send__(:#{method}, *args, &block)
|
||||
rescue ::Exception
|
||||
$@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
|
||||
$@.delete_if{|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
|
||||
::Kernel::raise
|
||||
end
|
||||
end
|
||||
|
@ -274,7 +274,7 @@ module SingleForwardable
|
|||
begin
|
||||
#{accessor}.__send__(:#{method}, *args, &block)
|
||||
rescue ::Exception
|
||||
$@.delete_if{|s| Forwardable::FILE_REGEXP =~ s} unless Forwardable::debug
|
||||
$@.delete_if{|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
|
||||
::Kernel::raise
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,6 +110,19 @@ class TestForwardable < Test::Unit::TestCase
|
|||
assert_not_match(/\/forwardable\.rb/, e.backtrace[0])
|
||||
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
|
||||
|
||||
def forwardable_class(&block)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue