ruby-changes:33669
From: usa <ko1@a...>
Date: Wed, 30 Apr 2014 16:26:40 +0900 (JST)
Subject: [ruby-changes:33669] usa:r45750 (ruby_2_0_0): merge revision(s) 45367, 45387, 45388, 45389: [Backport #9475]
usa 2014-04-30 16:26:33 +0900 (Wed, 30 Apr 2014) New Revision: 45750 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45750 Log: merge revision(s) 45367,45387,45388,45389: [Backport #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] * 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] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/test/ruby/test_alias.rb branches/ruby_2_0_0/version.h branches/ruby_2_0_0/vm_method.c Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 45749) +++ ruby_2_0_0/ChangeLog (revision 45750) @@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Wed Apr 30 16:15:09 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] + +Wed Apr 30 16:15:09 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] + Wed Apr 30 16:09:18 2014 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_callee_setup_arg): turn a macro into an Index: ruby_2_0_0/vm_method.c =================================================================== --- ruby_2_0_0/vm_method.c (revision 45749) +++ ruby_2_0_0/vm_method.c (revision 45750) @@ -534,8 +534,15 @@ rb_method_entry_get_without_cache(VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/vm_method.c#L534 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_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 45749) +++ ruby_2_0_0/version.h (revision 45750) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-04-30" -#define RUBY_PATCHLEVEL 470 +#define RUBY_PATCHLEVEL 471 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 4 Index: ruby_2_0_0/test/ruby/test_alias.rb =================================================================== --- ruby_2_0_0/test/ruby/test_alias.rb (revision 45749) +++ ruby_2_0_0/test/ruby/test_alias.rb (revision 45750) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_alias.rb#L1 require 'test/unit' +require 'envutil' class TestAlias < Test::Unit::TestCase class Alias0 @@ -129,4 +130,66 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_alias.rb#L130 def test_super_in_aliased_module_method # fails in 1.8 assert_equal([:Base, :M], SuperInAliasedModuleMethod::Derived.new.bar) 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_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45367,45387-45389 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/