From: "headius (Charles Nutter)" Date: 2012-11-05T13:49:19+09:00 Subject: [ruby-core:48880] [ruby-trunk - Bug #7269] Refinement doesn't work if using locate after method Issue #7269 has been updated by headius (Charles Nutter). I should also mention that if we can't tell ahead of time that a call site has to search refinements, it means all calls everywhere will have to have cref available. In JRuby, this could easily be a crippling blow to performance, and in MRI it would make it impossible to eliminate Ruby call frames (or eliminate cref management) ever in the future (which I'm sure ko1 would like to be able to do). Currently JRuby only needs the cref to be available if there's a closure, binding-related call, or constant lookup. We'd now have to make it available 100% of the time. It also means that you will never again be able to look at a piece of code and know if refinements will affect it. Refinements would become one of the most confusing features in Ruby. After talking with Yehuda a bit, I am more and more of the opinion that "using" should only affect call sites lexically in the same scope as (or a child scope of) the "using" call, and only call sites that appear after the "using" call. This would mean having to use "using" in every file where you want refinements active, but it would make it very where refinements are active both to the programmer and to the VM. ---------------------------------------- Bug #7269: Refinement doesn't work if using locate after method https://bugs.ruby-lang.org/issues/7269#change-32368 Author: ko1 (Koichi Sasada) Status: Open Priority: Normal Assignee: shugo (Shugo Maeda) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-11-01 trunk 37404) [i386-mswin32_100] Refinement doesn't work if using locate after method. (I eliminate discussion because my laptop doesn't have enough power...) class C def foo p :C_foo end end module M1 refine C do def foo p :M1_foo super end end end module M2 refine C do def foo p :M2_foo super end end end class D using M1 def x C.new.foo end using M2 end p :x D.new.x #=> :x :M1_foo :C_foo -- http://bugs.ruby-lang.org/