Issue #7274 has been updated by rits (First Last). matz (Yukihiro Matsumoto) wrote: > @rits You haven't read my message above, have you? > > >It is due to implementation limitation of CRuby. > > > >The structure of instances of subclass (TT_XXX) may be different from superclasses. > >In that case, the C implemented methods would crash. > > > >So we prohibit them conservatively. > > Matz. Neither I nor marcandre understood what you were alluding to and asked for a clarification, but you just repeated without clarifying. You appear to be saying, and please correct if that's wrong, that a method from a subclass can not safely be bound to an instance of a superclass. If so, please note, that is not what's being suggested. sub_foo, from the original example, is a method that is defined in the superclass, not the subclass. ---------------------------------------- Feature #7274: UnboundMethods should be bindable to any object that is_a?(owner of the UnboundMethod) https://bugs.ruby-lang.org/issues/7274#change-43153 Author: rits (First Last) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =begin as a corollary, (({UnboundMethod}))s referencing the same method name on the same owner, should be equal currently (({UnboundMethod}))s binding is determined by the class via which they were retrieved, not the owner class Base; def foo; end end class Sub < Base; end base_foo = Base.instance_method :foo sub_foo = Sub.instance_method :foo sub_foo.bind(Base.new).call (({sub_foo.owner})) is (({Base})) so there does not seem to be any reason why it's not safe for it to bind to an instance of (({Base})). and there does not seem to be any reason for (({sub_foo})) and (({base_foo})) to be unequal, they both refer to the same method, (({foo})) on (({Base})). =end -- http://bugs.ruby-lang.org/