Project

General

Profile

Actions

Bug #11425

closed

super_method fails to find the super method when combined with Module#prepend

Added by matsuda (Akira Matsuda) over 8 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-08-09 trunk 51513) [x86_64-darwin14]
[ruby-core:70286]

Description

super_method now fails to find the target method of Module#prepend maybe since 51501 https://github.com/ruby/ruby/commit/6b7c4df

class C; def a() end end
module M def a() end end
C.prepend M
p C.instance_method(:a).super_method
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
#=> #<UnboundMethod: Object(C)#a>

ruby 2.3.0dev (2015-08-09 trunk 51513) [x86_64-darwin14]
#=> nil

Files

bug11425.patch (935 Bytes) bug11425.patch matsuda (Akira Matsuda), 08/09/2015 08:19 PM

Updated by matsuda (Akira Matsuda) over 8 years ago

This happens only for UnboundMethod.

C.new.method(:a).super_method

correctly returns a Method.

Attached a patch with a failing test case.

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Description updated (diff)

Another issue, UnboundMethod#inspect in 2.2 also seems wrong.
It should be "#<UnboundMethod: C#a>".

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Description updated (diff)

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed

This was fixed between Ruby 2.3 and 2.4:

$ ruby23 -e '
> class C; def a() end end
> module M def a() end end
> C.prepend M
> p C.instance_method(:a).super_method
> '
nil
$ ruby24 -e '
> class C; def a() end end
> module M def a() end end
> C.prepend M
> p C.instance_method(:a).super_method
> '
#<UnboundMethod: C#a>
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0