Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refinements in method bodies aren't activated #3548

lazyatom opened this issue Dec 18, 2015 · 1 comment

Refinements in method bodies aren't activated #3548

lazyatom opened this issue Dec 18, 2015 · 1 comment


Copy link

(Moved from a comment in #1062)

I've hit some strange behaviour trying to use refinements with version

module Refinement
  refine Object do
    def new_method
      'new method!'

class Thing
  using Refinement

  p in_class_definition:

  def test
    p in_method:


{:in_class_definition=>"new method!"}
NoMethodError: undefined method `new_method' for #<Object:0xcfa9dbf>
   test at test.rb:15
  <top> at test.rb:19

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

@headius headius added this to the JRuby milestone Dec 22, 2015
headius added a commit that referenced this issue Apr 22, 2016
If you refine Integer, then calls against Fixnum should see that

Obviously this is super inefficient right now and caches nothing.

Relates to #3548.
Copy link

headius commented Apr 22, 2016

tldr: when a refined call occurred in a method body, we would accidentally skip that method's containing class when looking for refinements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants