[前][次][番号順一覧][スレッド一覧]

ruby-changes:40178

From: nobu <ko1@a...>
Date: Sat, 24 Oct 2015 07:29:41 +0900 (JST)
Subject: [ruby-changes:40178] nobu:r52259 (trunk): forwardable.rb: full qualify names

nobu	2015-10-24 07:29:14 +0900 (Sat, 24 Oct 2015)

  New Revision: 52259

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52259

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/lib/forwardable.rb
    trunk/test/test_forwardable.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52258)
+++ ChangeLog	(revision 52259)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 24 07:29:12 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@a...>
 
 	* iseq.c (make_compile_option_value): include frozen_string_literal*
Index: lib/forwardable.rb
===================================================================
--- lib/forwardable.rb	(revision 52258)
+++ lib/forwardable.rb	(revision 52259)
@@ -182,7 +182,7 @@ module Forwardable https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L182
         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 https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L274
         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
Index: test/test_forwardable.rb
===================================================================
--- test/test_forwardable.rb	(revision 52258)
+++ test/test_forwardable.rb	(revision 52259)
@@ -110,6 +110,19 @@ class TestForwardable < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/test_forwardable.rb#L110
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]