Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
[2.1] Refinements #1062
Refinements have been pared back to a much more reasonable form that does not have performance implications for unrefined code. They will ship as an official feature in 2.1.
We need to implement refinements in JRuby, at least as an experiment, as soon as possible to know whether they have undiscovered issues. Once they ship in 2.1 it will be much harder to fix them.
I'm marking this for 1.7.6, since I want to do the experiment ASAP.
I realized if I land this in its current 50%+ working state it will not work in JIT since in this form it still has a refinedcallinstr vs using a refinedcallsite. Even had I made that change the JIT would still need some work so I am deferring this until next 9k release.
I've hit some strange behaviour trying to use refinements with version 220.127.116.11:
module Refinement refine Object do def new_method 'new method!' end end end class Thing using Refinement p in_class_definition: Object.new.new_method def test p in_method: Object.new.new_method end end Thing.new.test
It seems like there's something amiss with the lexical scoping of the method; in MRI, methods defined with the lexical scope where a refinement is activated can make use of that refinement. Is this expected behaviour in JRuby as of 18.104.22.168?