-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
(Moved from a comment in #1062)
I've hit some strange behaviour trying to use refinements with version 9.0.4.0:
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.testoutputs
{: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 9.0.4.0?
Reactions are currently unavailable