Project

General

Profile

Actions

Bug #13973

closed

super_method fails on some UnboundMethods

Added by marcandre (Marc-Andre Lafortune) about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Target version:
ruby -v:
trunk
[ruby-core:83114]

Description

super_method fails to go up the ancestry chain for methods that are only defined in included modules:

module A
  def foo
  end
end

module B
  def foo
  end
end

class C
  include A
  include B
end

class D
  def foo
  end
  include A
  include B
end

C.instance_method(:foo) # => #<UnboundMethod: C(B)#foo> (ok)
C.instance_method(:foo).super_method # => nil (wrong, should be <UnboundMethod: <something>(A)#foo>)
C.new.method(:foo).super_method # => #<Method: Object(A)#foo> (ok)
D.instance_method(:foo).super_method # => #<UnboundMethod: Object(B)#foo> (ok)
D.instance_method(:foo).super_method.super_method # => #<UnboundMethod: Object(A)#foo> (ok)

Note that the results for C and D's super_method differ slightly, with one outputing "C(B)" and the other "Object(B)". I don't understand why "Object" shows anywhere in my example. I would have expected the output to be "D(B)" in the later case. Should I open a different issue for this?


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #14421: super_method segfaults when called on a re-bound MethodClosedActions
Related to Ruby master - Bug #15629: super_method fails on binded/unbinded/cloned methodsClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0