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

ruby-changes:46055

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 03:42:44 +0900 (JST)
Subject: [ruby-changes:46055] usa:r58126 (ruby_2_2): merge revision(s) 57362: [Backport #13096]

usa	2017-03-26 03:42:37 +0900 (Sun, 26 Mar 2017)

  New Revision: 58126

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

  Log:
    merge revision(s) 57362: [Backport #13096]
    
    vm_method.c: resolve refined method to undef
    
    * vm_method.c (rb_undef): resolve the method entry which refines a
      prepended method entry.  [ruby-core:78944] [Bug #13096]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/test/ruby/test_refinement.rb
    branches/ruby_2_2/version.h
    branches/ruby_2_2/vm_method.c
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58125)
+++ ruby_2_2/version.h	(revision 58126)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 458
+#define RUBY_PATCHLEVEL 459
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/vm_method.c
===================================================================
--- ruby_2_2/vm_method.c	(revision 58125)
+++ ruby_2_2/vm_method.c	(revision 58126)
@@ -923,7 +923,7 @@ rb_attr(VALUE klass, ID id, int read, in https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm_method.c#L923
 void
 rb_undef(VALUE klass, ID id)
 {
-    rb_method_entry_t *me;
+    const rb_method_entry_t *me;
 
     if (NIL_P(klass)) {
 	rb_raise(rb_eTypeError, "no class to undef method");
@@ -934,6 +934,9 @@ rb_undef(VALUE klass, ID id) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm_method.c#L934
     }
 
     me = search_method(klass, id, 0);
+    if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
+	me = rb_resolve_refined_method(Qnil, me, NULL);
+    }
 
     if (UNDEFINED_METHOD_ENTRY_P(me) ||
 	UNDEFINED_REFINED_METHOD_P(me->def)) {
Index: ruby_2_2/test/ruby/test_refinement.rb
===================================================================
--- ruby_2_2/test/ruby/test_refinement.rb	(revision 58125)
+++ ruby_2_2/test/ruby/test_refinement.rb	(revision 58126)
@@ -1387,6 +1387,25 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_refinement.rb#L1387
                    :foo, bug10826)
   end
 
+  def test_undef_prepended_method
+    bug13096 = '[ruby-core:78944] [Bug #13096]'
+    klass = EnvUtil.labeled_class("X") do
+      def foo; end
+    end
+    klass.prepend(Module.new)
+    ext = EnvUtil.labeled_module("Ext") do
+      refine klass do
+        def foo
+        end
+      end
+    end
+    assert_nothing_raised(NameError, bug13096) do
+      klass.class_eval do
+        undef :foo
+      end
+    end
+  end
+
   def test_call_refined_method_in_duplicate_module
     bug10885 = '[ruby-dev:48878]'
     assert_in_out_err([], <<-INPUT, [], [], bug10885)

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57362


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

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