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

ruby-changes:33874

From: nagachika <ko1@a...>
Date: Fri, 16 May 2014 00:24:22 +0900 (JST)
Subject: [ruby-changes:33874] nagachika:r45955 (ruby_2_1): merge revision(s) r45367, r45387, r45388, r45389: [Backport #9475]

nagachika	2014-05-16 00:24:05 +0900 (Fri, 16 May 2014)

  New Revision: 45955

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

  Log:
    merge revision(s) r45367,r45387,r45388,r45389: [Backport #9475]
    
    * vm_method.c (rb_method_entry_get_without_cache): get rid of
      infinite recursion at aliases in a subclass and a superclass.
      return actually defined class for other than singleton class.
      [ruby-core:60431] [Bug #9475]
    
    * vm_method.c (rb_method_entry_get_without_cache): me->klass is 0
      for a method aliased in a module.  [ruby-core:61636] [Bug #9663]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/test/ruby/test_alias.rb
    branches/ruby_2_1/version.h
    branches/ruby_2_1/vm_method.c
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 45954)
+++ ruby_2_1/ChangeLog	(revision 45955)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Fri May 16 00:14:25 2014  Kohei Suzuki  <eagletmt@g...>
+
+	* vm_method.c (rb_method_entry_get_without_cache): me->klass is 0
+	  for a method aliased in a module.  [ruby-core:61636] [Bug #9663]
+
+Fri May 16 00:14:25 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_method.c (rb_method_entry_get_without_cache): get rid of
+	  infinite recursion at aliases in a subclass and a superclass.
+	  return actually defined class for other than singleton class.
+	  [ruby-core:60431] [Bug #9475]
+
 Mon May 12 22:53:08 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (primary): flush cmdarg flags inside left-paren in a
Index: ruby_2_1/vm_method.c
===================================================================
--- ruby_2_1/vm_method.c	(revision 45954)
+++ ruby_2_1/vm_method.c	(revision 45955)
@@ -566,8 +566,15 @@ rb_method_entry_get_without_cache(VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_1/vm_method.c#L566
     VALUE defined_class;
     rb_method_entry_t *me = search_method(klass, id, &defined_class);
 
-    if (me && RB_TYPE_P(me->klass, T_ICLASS))
-	defined_class = me->klass;
+    if (me && me->klass) {
+	switch (BUILTIN_TYPE(me->klass)) {
+	  case T_CLASS:
+	    if (RBASIC(klass)->flags & FL_SINGLETON) break;
+	    /* fall through */
+	  case T_ICLASS:
+	    defined_class = me->klass;
+	}
+    }
 
     if (ruby_running) {
 	struct cache_entry *ent;
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 45954)
+++ ruby_2_1/version.h	(revision 45955)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
-#define RUBY_RELEASE_DATE "2014-05-12"
-#define RUBY_PATCHLEVEL 100
+#define RUBY_RELEASE_DATE "2014-05-16"
+#define RUBY_PATCHLEVEL 101
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 12
+#define RUBY_RELEASE_DAY 16
 
 #include "ruby/version.h"
 
Index: ruby_2_1/test/ruby/test_alias.rb
===================================================================
--- ruby_2_1/test/ruby/test_alias.rb	(revision 45954)
+++ ruby_2_1/test/ruby/test_alias.rb	(revision 45955)
@@ -132,4 +132,66 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_alias.rb#L132
       GC.verify_internal_consistency
     }
   end
+
+  def test_cyclic_zsuper
+    bug9475 = '[ruby-core:60431] [Bug #9475]'
+
+    a = Module.new do
+      def foo
+        "A"
+      end
+    end
+
+    b = Class.new do
+      include a
+      attr_reader :b
+
+      def foo
+        @b ||= 0
+        raise SystemStackError if (@b += 1) > 1
+        # "foo from B"
+        super + "B"
+      end
+    end
+
+    c = Class.new(b) do
+      alias orig_foo foo
+
+      def foo
+        # "foo from C"
+        orig_foo + "C"
+      end
+    end
+
+    b.class_eval do
+      alias orig_foo foo
+      attr_reader :b2
+
+      def foo
+        @b2 ||= 0
+        raise SystemStackError if (@b2 += 1) > 1
+        # "foo from B (again)"
+        orig_foo + "B2"
+      end
+    end
+
+    assert_nothing_raised(SystemStackError, bug9475) do
+      assert_equal("ABC", c.new.foo, bug9475)
+    end
+  end
+
+  def test_alias_in_module
+    bug9663 = '[ruby-core:61635] [Bug #9663]'
+
+    assert_separately(['-', bug9663], <<-'end;')
+      bug = ARGV[0]
+
+      m = Module.new do
+        alias orig_to_s to_s
+      end
+
+      o = Object.new.extend(m)
+      assert_equal(o.to_s, o.orig_to_s, bug)
+    end;
+  end
 end

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45367,45387-45389


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

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