Actions
Bug #7993
closedowner of methods defined after using Module#prepend
    Bug #7993:
    owner of methods defined after using Module#prepend
  
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-03-01 trunk 39546) [x86_64-linux]"
Backport:
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)
        
           Updated by marcandre (Marc-Andre Lafortune) over 12 years ago
          Updated by marcandre (Marc-Andre Lafortune) over 12 years ago
          
          
        
        
      
      Agreed. I described this in [ruby-core:52261], part of issue #7842.
        
           Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
          Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
          
          
        
        
      
      - Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44175.
Nobuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
proc.c, vm_method.c: fix super and alias
- proc.c (method_owner): return the class where alias is defined, not
 the class original method is defined.
- vm_method.c (rb_method_entry_make, rb_alias): store the originally
 defined class in me. [Bug #7993] [Bug #7842] [Bug #9236]
- vm_method.c (rb_method_entry_get_without_cache): cache included
 module but not iclass.
        
           Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
          Updated by nobu (Nobuyoshi Nakada) almost 12 years ago
          
          
        
        
      
      - Backport set to 1.9.3: DONTNEED, 2.0.0: REQUIRED
        
           Updated by nagachika (Tomoyuki Chikanaga) almost 12 years ago
          Updated by nagachika (Tomoyuki Chikanaga) almost 12 years ago
          
          
        
        
      
      - Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE
r44175 and r44179 were backported to ruby_2_0_0 at r44345, and additionally r44198 was backported at 44366.
See #9236 too.
        
           Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          
          
        
        
      
      - Description updated (diff)
        
           Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          
          
        
        
      
      - Related to Bug #7987: Method#parameters should consider a prepended or refined methd added
Actions