From: mon.ouie@... Date: 2017-07-29T09:19:25+00:00 Subject: [ruby-core:82209] [Ruby trunk Bug#13776] Refined methods ignore visibility of inherited methods Issue #13776 has been reported by Mon_Ouie (Mon ou��e). ---------------------------------------- Bug #13776: Refined methods ignore visibility of inherited methods https://bugs.ruby-lang.org/issues/13776 * Author: Mon_Ouie (Mon ou��e) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.0dev (2017-07-28 trunk 59438) [x86_64-linux] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- This bug was pointed out by al2o3-cr on the #ruby IRC channel on freenode. The following code sleeps for 3 seconds, even though ``String#sleep`` is a private method. module Test refine String do def sleep; end end end puts "start" "".sleep 3 puts "end" This happens because ``vm_call_method_each_type``, when running a method of type ``VM_METHOD_TYPE_REFINED``, uses ``vm_call_zsuper`` to call inherited methods, which does not check the visibility of the method and directly executes it. I attached a patch which changes this code path and uses ``vm_call_method`` to trigger the code that honors method visibilities. I have not played extensively with this patch, but it at least does not seem to break any existing unit tests. ---Files-------------------------------- refinement.patch (1.74 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: