Projects

Ticket #185 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Redefining singleton methods on multiple objects at the same place

Reported by: vincent.isambart@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby 0.5
Component: MacRuby Keywords:
Cc:

Description

The following code causes a warning. The problem is when 2 different objects have a method defined on their singleton class at the same place.

def func(obj)
  def obj.a
    p self.description
    p self.class.ancestors
    super
  end
end

class A
  def a
  end
end

o1 = A.new
o2 = A.new
func(o1)
func(o2)
puts 'o1'
o1.a
puts 'o2'
o2.a

Change History

Changed 2 years ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.5

It seems that trunk doesn't raise any warning anymore.

$ ./miniruby t.rb 
o1
"#<A:0x20004c440>"
[#<Class:#<A:0x20004c440>>, A, NSObject, Kernel]
o2
"#<A:0x20004c400>"
[#<Class:#<A:0x20004c400>>, A, NSObject, Kernel]

I ran the same file with 1.9 after commenting the #description call, it seems to produce the same results.

Note: See TracTickets for help on using tickets.