From 179384a66862d5ef7413b6f4850b97d0becf4ec9 Mon Sep 17 00:00:00 2001 From: Jeremy Evans 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] --- spec/ruby/core/module/refine_spec.rb | 79 +++++++++--------------------------- 1 file changed, 20 insertions(+), 59 deletions(-) (limited to 'spec/ruby/core') diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index cb50fcbce6..54217a9326 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 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 -- cgit v1.2.3