[Ironruby-core] Annoymous class extending a module doesn't return expected kind_of

Ben Hall ben2004uk at googlemail.com
Sun Oct 5 21:28:16 EDT 2008


Hi guys,

I've been bashing my head again this problem for the last few days
where the object I expected wasn't passed around, tonight I decided to
break it down and focus on a much small part.  Turns out, I was
looking in the wrong part.

This is what I think the problem is. The code is creating an anonymous
class which is extending a module.  The code then does a kind_of? to
decide what to do with it.

>From what I can tell, it looks like the kind_of doesn't recognize the
modules it is extending.  This is the code which demonstrates the
problem:

Code Repro:
module AAA
   class << self
     def a
      puts "Hello"
     end
   end

  def myAAA
    klass = Class.new do
        extend AAA
    end

    puts "Am I a type of what I extended (AAA)?"
    puts klass.kind_of?(AAA)
  end
end

class XYZ
  include AAA
end

$a = XYZ.new
$a.myAAA


With MRI, true is returned.  With IronRuby, false is returned.

Output:

E:\IronRuby\trunk\build\debug>ruby array_test
Am I a type of what I extended (AAA)?
true

E:\IronRuby\trunk\build\debug>ir array_test
Am I a type of what I extended (AAA)?
false


This has blocked me moving on.  Anyone got any ideas?

Any help on this would be great!

Thanks

Ben
Blog.BenHall.me.uk


More information about the Ironruby-core mailing list