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

ruby-changes:45834

From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 22:47:00 +0900 (JST)
Subject: [ruby-changes:45834] naruse:r57907 (ruby_2_4): merge revision(s) 57655: [Backport #13227]

naruse	2017-03-12 22:46:55 +0900 (Sun, 12 Mar 2017)

  New Revision: 57907

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

  Log:
    merge revision(s) 57655: [Backport #13227]
    
    vm_insnhelper.c: super to module in refinement
    
    * vm_insnhelper.c (vm_call_zsuper): method defined in module in
      refinement is not callable as-is.  dispatch again.
      [ruby-core:79588] [Bug #13227]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/test/ruby/test_refinement.rb
    branches/ruby_2_4/version.h
    branches/ruby_2_4/vm_insnhelper.c
Index: ruby_2_4/vm_insnhelper.c
===================================================================
--- ruby_2_4/vm_insnhelper.c	(revision 57906)
+++ ruby_2_4/vm_insnhelper.c	(revision 57907)
@@ -2026,7 +2026,8 @@ vm_call_zsuper(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_insnhelper.c#L2026
     if (!cc->me) {
 	return vm_call_method_nome(th, cfp, calling, ci, cc);
     }
-    if (cc->me->def->type == VM_METHOD_TYPE_REFINED) {
+    if (cc->me->def->type == VM_METHOD_TYPE_REFINED &&
+	cc->me->def->body.refined.orig_me) {
 	cc->me = refined_method_callable_without_refinement(cc->me);
     }
     return vm_call_method_each_type(th, cfp, calling, ci, cc);
Index: ruby_2_4/test/ruby/test_refinement.rb
===================================================================
--- ruby_2_4/test/ruby/test_refinement.rb	(revision 57906)
+++ ruby_2_4/test/ruby/test_refinement.rb	(revision 57907)
@@ -1829,6 +1829,38 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_refinement.rb#L1829
     end;
   end
 
+  module SuperToModule
+    class Parent
+    end
+
+    class Child < Parent
+    end
+
+    module FooBar
+      refine Parent do
+        def to_s
+          "Parent"
+        end
+      end
+
+      refine Child do
+        def to_s
+          super + " -> Child"
+        end
+      end
+    end
+
+    using FooBar
+    def Child.test
+      new.to_s
+    end
+  end
+
+  def test_super_to_module
+    bug = '[ruby-core:79588] [Bug #13227]'
+    assert_equal("Parent -> Child", SuperToModule::Child.test, bug)
+  end
+
   private
 
   def eval_using(mod, s)
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 57906)
+++ ruby_2_4/version.h	(revision 57907)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-12"
-#define RUBY_PATCHLEVEL 64
+#define RUBY_PATCHLEVEL 65
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57655


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

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