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

ruby-changes:13377

From: nobu <ko1@a...>
Date: Tue, 29 Sep 2009 13:38:09 +0900 (JST)
Subject: [ruby-changes:13377] Ruby:r25147 (trunk): * vm_method.c (rb_add_method_def): nothing to do if old method had

nobu	2009-09-29 13:37:52 +0900 (Tue, 29 Sep 2009)

  New Revision: 25147

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

  Log:
    * vm_method.c (rb_add_method_def): nothing to do if old method had
      same definition.  [ruby-dev:39397]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_class.rb
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25146)
+++ ChangeLog	(revision 25147)
@@ -1,3 +1,8 @@
+Tue Sep 29 13:37:50 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_method.c (rb_add_method_def): nothing to do if old method had
+	  same definition.  [ruby-dev:39397]
+
 Tue Sep 29 06:50:32 2009  NARUSE, Yui  <naruse@r...>
 
 	* string.c (rb_str_inspect): dump as \uXXXX when the
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 25146)
+++ vm_method.c	(revision 25147)
@@ -141,6 +141,8 @@
     xfree(me);
 }
 
+static int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
+
 static rb_method_entry_t *
 rb_add_method_def(VALUE klass, ID mid, rb_method_type_t type, rb_method_definition_t *def, rb_method_flag_t noex)
 {
@@ -179,7 +181,7 @@
 	rb_method_entry_t *old_me = (rb_method_entry_t *)data;
 	rb_method_definition_t *old_def = old_me->def;
 
-	if (old_def == def) return old_me;
+	if (rb_method_definition_eq(old_def, def)) return old_me;
 	rb_vm_check_redefinition_opt_method(old_me);
 
 	if (RTEST(ruby_verbose) &&
@@ -791,7 +793,12 @@
 int
 rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2)
 {
-    const rb_method_definition_t *d1 = m1->def, *d2 = m2->def;
+    return rb_method_definition_eq(m1->def, m2->def);
+}
+
+static int
+rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2)
+{
     if (!d1) {
 	return !d2;
     }
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 25146)
+++ test/ruby/test_class.rb	(revision 25147)
@@ -130,6 +130,14 @@
       end
     end
     assert_equal("", stderr)
+    stderr = verbose_warning do
+      Module.new do
+        module_function
+        def foo; end
+        module_function :foo
+      end
+    end
+    assert_equal("", stderr, '[ruby-dev:39397]')
   end
 
   def test_check_inheritable

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

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