diff options
| author | Jeremy Evans <code@jeremyevans.net> | 2020-07-10 14:38:00 -0700 |
|---|---|---|
| committer | Jeremy Evans <code@jeremyevans.net> | 2020-07-27 08:18:11 -0700 |
| commit | eeef16e190cdabc2ba474622720f8e3df7bac43b (patch) | |
| tree | 9d238fbd2ee801743f4c1f31c7f162ddba84bb23 /test | |
| parent | cb5127927a2b6ac4fa143dff44d4d896ed4a6372 (diff) | |
Prevent SystemStackError when calling super in module with activated refinement
Without this, if a refinement defines a method that calls super and
includes a module with a module that calls super and has a activated
refinement at the point super is called, the module method super call
will end up calling back into the refinement method, creating a loop.
Fixes [Bug #17007]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3309
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_refinement.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 785113de77..e4a5cd25d2 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -484,6 +484,37 @@ class TestRefinement < Test::Unit::TestCase 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 { |
