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 for some ("global") classes/modules not working #5220

Closed
palkan opened this issue Jun 17, 2018 · 2 comments
Closed

Refinements for some ("global") classes/modules not working #5220

palkan opened this issue Jun 17, 2018 · 2 comments
Milestone

Comments

@palkan
Copy link

palkan commented Jun 17, 2018

Environment

  • JRuby version: jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-1~deb9u1-b11 +jit [linux-x86_64]
  • Operating system and platform: Linux 3971953e9581 4.9.49-moby break script engine #1 SMP Fri Dec 8 13:40:02 UTC 2017 x86_64 GNU/Linux

Expected Behavior

The following refinements are expected to work (as they are in CRuby):

module ObjectExt
  # the same with BasicObject and Kernel 
  refine Object do
    def i_am_refined
      'i_am_refined'
    end
  end
end

using ObjectExt

class Test; end

p Test.new.i_am_refined

Actual Behavior

NoMethodError: undefined method `i_am_refined' for #<Test:0x2d8f65a4>

Other non-refineables:

  • Module
  • Numeric:

This doesn't work:

module NumericExt
  refine Numeric do
    def i_am_refined
      'i_am_refined'
    end
  end
end

using NumericExt

1.i_am_refined

Although this works:

module NumericExt
  refine Integer do
    def i_am_refined
      'i_am_refined'
    end
  end
end

using NumericExt

1.i_am_refined
@palkan palkan changed the title Refinements for some classes/modules not working Refinements for some ("global") classes/modules not working Jun 17, 2018
@palkan
Copy link
Author

palkan commented Jun 17, 2018

Probably a duplicate of #4330.

And the Numeric example looks like #4288 (but it's closed).

@headius headius added this to the JRuby 9.2.7.0 milestone Apr 12, 2019
@headius
Copy link
Member

headius commented Apr 12, 2019

Fixed in 9.2.7 with the refinements work.

@headius headius closed this as completed Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants