-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
Likely the same root cause as #4228
Environment
- jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 25.72-b15 on 1.8.0_72-b15 +jit [darwin-x86_64]
- Darwin Evans-2015-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64
Expected Behavior
A singleton method that is cloned and then redefined is overwritten, not overridden.
MRI
class Foo
def bar
puts 'class method'
end
end
object = Foo.new
object.define_singleton_method(:bar) do
puts 'instance method 1'
super()
end
cloned = object.clone
cloned.define_singleton_method(:bar) do
puts 'instance method 2'
super()
end
cloned.bar
#=> instance method 2
#=> class methodActual Behavior
class Foo
def bar
puts 'class method'
end
end
object = Foo.new
object.define_singleton_method(:bar) do
puts 'instance method 1'
super()
end
cloned = object.clone
cloned.define_singleton_method(:bar) do
puts 'instance method 2'
super()
end
cloned.bar
#=> instance method 2
#=> instance method 1
#=> class methodReactions are currently unavailable