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

ruby-changes:63043

From: Jeremy <ko1@a...>
Date: Wed, 23 Sep 2020 04:05:05 +0900 (JST)
Subject: [ruby-changes:63043] 179384a668 (master): Revert "Prevent SystemStackError when calling super in module with activated refinement"

https://git.ruby-lang.org/ruby.git/commit/?id=179384a668

From 179384a66862d5ef7413b6f4850b97d0becf4ec9 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Tue, 22 Sep 2020 09:40:45 -0700
Subject: Revert "Prevent SystemStackError when calling super in module with
 activated refinement"

This reverts commit eeef16e190cdabc2ba474622720f8e3df7bac43b.

This also reverts the spec change.

Preventing the SystemStackError would be nice, but there is valid
code that the fix breaks, and it is probably more common than cases
that cause the SystemStackError.

Fixes [Bug #17182]

diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb
index cb50fcb..54217a9 100644
--- a/spec/ruby/core/module/refine_spec.rb
+++ b/spec/ruby/core/module/refine_spec.rb
@@ -980,77 +980,38 @@ describe "Module#refine" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/module/refine_spec.rb#L980
       result.should == [:B, :A, :LAST, :C]
     end
 
-    ruby_version_is ""..."3.0" do
-      it "looks in the lexical scope refinements before other active refinements" do
-        refined_class = ModuleSpecs.build_refined_class(for_super: true)
-
-        refinement_local = Module.new do
-          refine refined_class do
-            def foo
-              [:LOCAL] + super
-            end
-          end
-        end
-
-        a = Module.new do
-          using refinement_local
+    it "looks in the lexical scope refinements before other active refinements" do
+      refined_class = ModuleSpecs.build_refined_class(for_super: true)
 
+      refinement_local = Module.new do
+        refine refined_class do
           def foo
-            [:A] + super
+            [:LOCAL] + super
           end
         end
-
-        refinement = Module.new do
-          refine refined_class do
-            include a
-          end
-        end
-
-        result = nil
-        Module.new do
-          using refinement
-          result = refined_class.new.foo
-        end
-
-        result.should == [:A, :LOCAL, :C]
       end
-    end
-
-    ruby_version_is "3.0" do
-      # https://bugs.ruby-lang.org/issues/17007
-      it "does not look in the lexical scope refinements before other active refinements" do
-        refined_class = ModuleSpecs.build_refined_class(for_super: true)
 
-        refinement_local = Module.new do
-          refine refined_class do
-            def foo
-              [:LOCAL] + super
-            end
-          end
-        end
-
-        a = Module.new do
-          using refinement_local
-
-          def foo
-            [:A] + super
-          end
-        end
+      a = Module.new do
+        using refinement_local
 
-        refinement = Module.new do
-          refine refined_class do
-            include a
-          end
+        def foo
+          [:A] + super
         end
+      end
 
-        result = nil
-        Module.new do
-          using refinement
-          result = refined_class.new.foo
+      refinement = Module.new do
+        refine refined_class do
+          include a
         end
+      end
 
-        result.should == [:A, :C]
+      result = nil
+      Module.new do
+        using refinement
+        result = refined_class.new.foo
       end
+
+      result.should == [:A, :LOCAL, :C]
     end
   end
 
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index e4a5cd2..785113d 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -484,37 +484,6 @@ class TestRefinement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L484
     assert_equal("M#baz C#baz", RefineModule.call_baz)
   end
 
-  module RefineIncludeActivatedSuper
-    class C
-      def foo
-        ["C"]
-      end
-    end
-
-    module M; end
-
-    refinement = Module.new do
-      R = refine C do
-        def foo
-          ["R"] + super
-        end
-
-        include M
-      end
-    end
-
-    using refinement
-    M.define_method(:foo){["M"] + super()}
-
-    def self.foo
-      C.new.foo
-    end
-  end
-
-  def test_refine_include_activated_super
-    assert_equal(["R", "M", "C"], RefineIncludeActivatedSuper.foo)
-  end
-
   def test_refine_neither_class_nor_module
     assert_raise(TypeError) do
       Module.new {
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 6f725a2..ec1b143 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3043,9 +3043,6 @@ search_refined_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struc https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3043
         if (ref_me) {
             if (vm_cc_call(cc) == vm_call_super_method) {
                 const rb_control_frame_t *top_cfp = current_method_entry(ec, cfp);
-                if (refinement == find_refinement(CREF_REFINEMENTS(vm_get_cref(top_cfp->ep)), vm_cc_cme(cc)->owner)) {
-                    continue;
-                }
                 const rb_callable_method_entry_t *top_me = rb_vm_frame_method_entry(top_cfp);
                 if (top_me && rb_method_definition_eq(ref_me->def, top_me->def)) {
                     continue;
-- 
cgit v0.10.2


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

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