From 0948eb62e68d559e0a42732c896fe9957b8d6b80 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 8 Jan 2018 09:04:07 +0000 Subject: vm.c: respect redefinition of Proc#call * vm.c (vm_redefinition_check_method_type): hoist out method definition type to check redefinition. * vm.c (rb_vm_check_redefinition_opt_method): should check optimized method too. * vm.c (vm_init_redefined_flag): check Proc#call. * vm_insnhelper.c (vm_call_opt_block_call): search proper method if redefined. [Bug #14335] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_proc.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/ruby/test_proc.rb') diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 701bd078ca..69cb0e439b 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -1390,4 +1390,22 @@ class TestProc < Test::Unit::TestCase e.each {} EOS end + + def test_prepended_call + assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", ["call"]) + begin; + Proc.prepend Module.new {def call() puts "call"; super; end} + def m(&blk) blk.call; end + m {} + end; + end + + def test_refined_call + assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", ["call"]) + begin; + using Module.new {refine(Proc) {def call() puts "call"; super; end}} + def m(&blk) blk.call; end + m {} + end; + end end -- cgit v1.2.3