Project

General

Profile

Actions

Bug #7993

closed

owner of methods defined after using Module#prepend

Added by no6v (Nobuhiro IMAI) about 11 years ago. Updated about 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]"
[ruby-core:53070]

Description

The owner of methods defined after using Module#prepend seems to be incorrect.

RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]"

class C
  attr_reader :a
  prepend Module.new
  attr_reader :b
end
C.instance_method(:a).owner # => C
C.instance_method(:b).owner # => #<C:0x00000000a52300>
C.new.method(:a).owner      # => C
C.new.method(:b).owner      # => #<C:0x00000000a52300>

module M
  attr_reader :a
  prepend Module.new
  attr_reader :b
end
M.instance_method(:a).owner # => M
M.instance_method(:b).owner # =>
# ~> -:19:in `<main>': undefined method `class' for #<M:0x00000000a515b8> (NoMethodError)

Related issues 3 (0 open3 closed)

Related to Ruby master - Bug #7987: Method#parameters should consider a prepended or refined methdClosed02/28/2013Actions
Is duplicate of Ruby master - Bug #7842: An alias of a "prepend"ed method skips the original method when calling superClosednobu (Nobuyoshi Nakada)02/13/2013Actions
Has duplicate Ruby master - Bug #8817: Method#owner on prepended classes is an instance rather than Class/Method Closed08/25/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0