Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Not A Bug
-
Affects Version/s: JRuby 0.9.8
-
Fix Version/s: JRuby 1.x+
-
Component/s: Interpreter
-
Labels:None
Description
What a tangled mess....So first lets run this:
class Parent def lol() puts "P: LOL" end end class Child < Parent def lol() puts "C: LOL" end end c = Child.new Child.class_eval { undef_method :lol } class Child #< Parent def lol print "LOL: " super rescue NameError => e puts e.to_s end end c.lol
This should print out:
LOL: superclass method `lol' disabled
If we look at this example it appears like the instance is created before redefinition. However that appears to be unrelated:
class Parent def lol() puts "P: LOL" end end class Child < Parent def lol() puts "C: LOL" end end Child.class_eval { undef_method :lol } class Child #< Parent def lol print "LOL: " super rescue NameError => e puts e.to_s end end c = Child.new c.lol
Same result.
So it appears that ever undef'ing a method pretty much disables the ability to go to the super method. Why?
In any case we do not do this correctly, this test case is putting a dampening effect on my rubyclass elimination refactoring...
I'd recommend asking ruby-core about this. It almost seems like a bug in Ruby that you can't undef a method and redefine it and expect super to work. I can't think of any good reason why it shouldn't be the intuitive way...