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

ruby-changes:33308

From: nobu <ko1@a...>
Date: Sun, 23 Mar 2014 11:03:56 +0900 (JST)
Subject: [ruby-changes:33308] nobu:r45387 (trunk): vm_method.c: check if klass is 0

nobu	2014-03-23 11:03:51 +0900 (Sun, 23 Mar 2014)

  New Revision: 45387

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

  Log:
    vm_method.c: check if klass is 0
    
    * 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 files:
    trunk/ChangeLog
    trunk/test/ruby/test_alias.rb
    trunk/vm_method.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45386)
+++ ChangeLog	(revision 45387)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar 23 11:03:27 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]
+
 Sun Mar 23 08:12:27 2014  Eric Wong  <e@8...>
 
 	* st.c (hash_pos): use bitwise AND to avoid slow modulo op
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 45386)
+++ vm_method.c	(revision 45387)
@@ -578,7 +578,7 @@ rb_method_entry_get_without_cache(VALUE https://github.com/ruby/ruby/blob/trunk/vm_method.c#L578
     VALUE defined_class;
     rb_method_entry_t *me = search_method(klass, id, &defined_class);
 
-    if (me) {
+    if (me && !me->klass) {
 	switch (BUILTIN_TYPE(me->klass)) {
 	  case T_CLASS:
 	    if (RBASIC(klass)->flags & FL_SINGLETON) break;
Index: test/ruby/test_alias.rb
===================================================================
--- test/ruby/test_alias.rb	(revision 45386)
+++ test/ruby/test_alias.rb	(revision 45387)
@@ -179,4 +179,19 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_alias.rb#L179
       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

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

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