IronRuby 0.9.2 bug - Can't define a singleton method on a COM object instance

This code used to work under IronRuby 0.9.1 and earlier

load_assembly “microsoft.office.word.interop”
word = Microsoft::office::Interop::Word::ApplicationClass.new

metaclass = class << word; self; end
metaclass.send :define_method, “fizz” do |*args|
puts “hello”
end #BANG!

Under 0.9.2, this happens

NoMethodError: private method singleton_method_added' called for Microsoft.Office.Interop.Word.ApplicationClass:Microsoft::Office::Interop::Word::ApplicationClass from (irb):52 from :0:indefine_method’
from :0:in define_method' from :0:insend’
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:146:in eval_input' from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:70:instart’
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:69:in start' from :0:ineval’
from workspace.rb:80:in evaluate' from context.rb:217:inevaluate’
from irb.rb:147:in eval_input' from irb.rb:257:insignal_status’
from irb.rb:146:in eval_input' from ruby-lex.rb:230:ineach_top_level_statement’
from :0:in loop' from C:/Dev/TEST/ruby/bin/iirb:13 from :0:incatch’
from :0:i

While the previous bug (calling super from method_missing on a COM
object)
was easy to work around and isn’t that important in the scheme of
things,
this one is a real blocker :frowning: Might have to roll back to 0.9.1 :frowning:

You might be able to work this around by making singleton_method_added a
public method.

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Orion E.
Sent: Sunday, November 08, 2009 6:43 PM
To: [email protected]
Subject: [Ironruby-core] IronRuby 0.9.2 bug - Can’t define a singleton
method on a COM object instance

This code used to work under IronRuby 0.9.1 and earlier

load_assembly “microsoft.office.word.interop”
word = Microsoft::office::Interop::Word::ApplicationClass.new

metaclass = class << word; self; end
metaclass.send :define_method, “fizz” do |*args|
puts “hello”
end #BANG!

Under 0.9.2, this happens

NoMethodError: private method singleton_method_added' called for Microsoft.Office.Interop.Word.ApplicationClass:Microsoft::Office::Interop::Word::ApplicationClass from (irb):52 from :0:in define_method’
from :0:in define_method' from :0:in send’
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:146:in eval_input' from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:70:in start’
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:69:in start' from :0:in eval’
from workspace.rb:80:in evaluate' from context.rb:217:in evaluate’
from irb.rb:147:in eval_input' from irb.rb:257:in signal_status’
from irb.rb:146:in eval_input' from ruby-lex.rb:230:in each_top_level_statement’
from :0:in loop' from C:/Dev/TEST/ruby/bin/iirb:13 from :0:in catch’
from :0:i

While the previous bug (calling super from method_missing on a COM
object) was easy to work around and isn’t that important in the scheme
of things, this one is a real blocker :frowning: Might have to roll back to
0.9.1 :frowning: