Project

General

Profile

Bug #13973

super_method fails on some UnboundMethods

Added by marcandre (Marc-Andre Lafortune) over 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
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

Related to Ruby trunk - Bug #14421: super_method segfaults when called on a re-bound MethodClosedActions

Associated revisions

Revision a15028bc
Added by nobu (Nobuyoshi Nakada) over 1 year ago

proc.c: super_method of included method

  • proc.c (method_super_method): search the next super method along
    the included ancestor chain. [ruby-core:83114] [Bug #13973]

  • vm_method.c (rb_callable_method_entry_without_refinements):
    return the defined class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60127
Added by nobu (Nobuyoshi Nakada) over 1 year ago

proc.c: super_method of included method

  • proc.c (method_super_method): search the next super method along
    the included ancestor chain. [ruby-core:83114] [Bug #13973]

  • vm_method.c (rb_callable_method_entry_without_refinements):
    return the defined class.

Revision 60127
Added by nobu (Nobuyoshi Nakada) over 1 year ago

proc.c: super_method of included method

  • proc.c (method_super_method): search the next super method along
    the included ancestor chain. [ruby-core:83114] [Bug #13973]

  • vm_method.c (rb_callable_method_entry_without_refinements):
    return the defined class.

Revision 60127
Added by nobu (Nobuyoshi Nakada) over 1 year ago

proc.c: super_method of included method

  • proc.c (method_super_method): search the next super method along
    the included ancestor chain. [ruby-core:83114] [Bug #13973]

  • vm_method.c (rb_callable_method_entry_without_refinements):
    return the defined class.

Revision 9e7b5784
Added by nagachika (Tomoyuki Chikanaga) 11 months ago

merge revision(s) 58245,60127: [Backport #13973]

Refactored using Method#owner.


proc.c: super_method of included method

* proc.c (method_super_method): search the next super method along
  the included ancestor chain.  [ruby-core:83114] [Bug #13973]

* vm_method.c (rb_callable_method_entry_without_refinements):
  return the defined class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62865
Added by nagachika (Tomoyuki Chikanaga) 11 months ago

merge revision(s) 58245,60127: [Backport #13973]

Refactored using Method#owner.


proc.c: super_method of included method

* proc.c (method_super_method): search the next super method along
  the included ancestor chain.  [ruby-core:83114] [Bug #13973]

* vm_method.c (rb_callable_method_entry_without_refinements):
  return the defined class.

History

#1

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60127.


proc.c: super_method of included method

  • proc.c (method_super_method): search the next super method along
    the included ancestor chain. [ruby-core:83114] [Bug #13973]

  • vm_method.c (rb_callable_method_entry_without_refinements):
    return the defined class.

#2

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Related to Bug #14421: super_method segfaults when called on a re-bound Method added

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED

I have noticed this ticket during searching changesets related with r62115.
I think r60127 should be backported, but you should backport r62115 too. See #14421.

Updated by nagachika (Tomoyuki Chikanaga) 11 months ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED to 2.3: REQUIRED, 2.4: DONE

ruby_2_4 r62865 merged revision(s) 58245,60127.

Also available in: Atom PDF