ruby-changes:13325
From: nobu <ko1@a...>
Date: Fri, 25 Sep 2009 13:05:02 +0900 (JST)
Subject: [ruby-changes:13325] Ruby:r25089 (trunk): * proc.c (mnew): fix for instance method of Module, BasicObject
nobu 2009-09-25 13:04:48 +0900 (Fri, 25 Sep 2009) New Revision: 25089 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25089 Log: * proc.c (mnew): fix for instance method of Module, BasicObject and subclass of a class which overrides respond_to_missing?. based on a patch from Nikolai Lugovoi <nlugovoi AT gmail.com> in [ruby-core:25748]. Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_object.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 25088) +++ ChangeLog (revision 25089) @@ -1,3 +1,10 @@ +Fri Sep 25 13:04:46 2009 Nobuyoshi Nakada <nobu@r...> + + * proc.c (mnew): fix for instance method of Module, BasicObjec + and subclass of a class which overrides respond_to_missing?. + based on a patch from Nikolai Lugovoi <nlugovoi AT gmail.com> in + [ruby-core:25748]. + Fri Sep 25 11:56:50 2009 Nobuyoshi Nakada <nobu@r...> * vm_method.c (rb_mod_method_defined): should return true or false. Index: proc.c =================================================================== --- proc.c (revision 25088) +++ proc.c (revision 25089) @@ -912,7 +912,7 @@ ID rmiss = rb_intern("respond_to_missing?"); VALUE sym = ID2SYM(id); - if (!rb_method_basic_definition_p(klass, rmiss)) { + if (obj != Qundef && !rb_method_basic_definition_p(klass, rmiss)) { if (RTEST(rb_funcall(obj, rmiss, 1, sym))) { return rb_proc_new(missing_wrap, rb_assoc_new(obj, sym)); } Index: test/ruby/test_object.rb =================================================================== --- test/ruby/test_object.rb (revision 25088) +++ test/ruby/test_object.rb (revision 25089) @@ -305,8 +305,7 @@ end def test_respond_to_missing - c = Class.new - c.class_eval do + c = Class.new do def respond_to_missing?(id) if id == :foobar true @@ -335,6 +334,18 @@ foobar = foo.method(:foobar) assert_equal([:foo], foobar.call); assert_equal([:foo, 1], foobar.call(1)); + + c = Class.new(c) + assert_equal(false, c.method_defined?(:foobar)) + assert_raise(NameError, '[ruby-core:25748]') do + c.instance_method(:foobar) + end + + m = Module.new + assert_equal(false, m.method_defined?(:foobar)) + assert_raise(NameError, '[ruby-core:25748]') do + m.instance_method(:foobar) + end end def test_send_with_no_arguments -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/