ruby-changes:40689
From: nagachika <ko1@a...>
Date: Sat, 28 Nov 2015 05:32:20 +0900 (JST)
Subject: [ruby-changes:40689] nagachika:r52768 (ruby_2_2): merge revision(s) 50737: [Backport #11211]
nagachika 2015-11-28 05:31:58 +0900 (Sat, 28 Nov 2015) New Revision: 52768 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52768 Log: merge revision(s) 50737: [Backport #11211] * insns.def (defined): skip respond_to_missing? when a method is available. [Bug #11211] * test/ruby/test_defined.rb: add a test for this fix. Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/insns.def branches/ruby_2_2/test/ruby/test_defined.rb branches/ruby_2_2/version.h Index: ruby_2_2/insns.def =================================================================== --- ruby_2_2/insns.def (revision 52767) +++ ruby_2_2/insns.def (revision 52768) @@ -740,15 +740,12 @@ defined https://github.com/ruby/ruby/blob/trunk/ruby_2_2/insns.def#L740 const rb_method_entry_t *me = rb_method_entry(klass, SYM2ID(obj), 0); if (me) { - if (!(me->flag & NOEX_PRIVATE)) { - if (!((me->flag & NOEX_PROTECTED) && - !rb_obj_is_kind_of(GET_SELF(), - rb_class_real(klass)))) { - expr_type = DEFINED_METHOD; - } + if (!(me->flag & NOEX_PRIVATE) && + !((me->flag & NOEX_PROTECTED) && !rb_obj_is_kind_of(GET_SELF(), rb_class_real(klass)))) { + expr_type = DEFINED_METHOD; } } - { + else { VALUE args[2]; VALUE r; Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 52767) +++ ruby_2_2/ChangeLog (revision 52768) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sat Nov 28 05:21:06 2015 Koichi Sasada <ko1@a...> + + * insns.def (defined): skip respond_to_missing? when + a method is available. + [Bug #11211] + + * test/ruby/test_defined.rb: add a test for this fix. + Wed Nov 25 01:05:29 2015 CHIKANAGA Tomoyuki <nagachika@r...> * ext/digest/sha1/sha1ossl.c: fix defs.h path to catch up changes in Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 52767) +++ ruby_2_2/version.h (revision 52768) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.4" -#define RUBY_RELEASE_DATE "2015-11-25" -#define RUBY_PATCHLEVEL 200 +#define RUBY_RELEASE_DATE "2015-11-28" +#define RUBY_PATCHLEVEL 201 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 28 #include "ruby/version.h" Index: ruby_2_2/test/ruby/test_defined.rb =================================================================== --- ruby_2_2/test/ruby/test_defined.rb (revision 52767) +++ ruby_2_2/test/ruby/test_defined.rb (revision 52768) @@ -208,4 +208,29 @@ class TestDefined < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_defined.rb#L208 def test_super_toplevel assert_separately([], "assert_nil(defined?(super))") end + + class ExampleRespondToMissing + attr_reader :called + + def initialize + @called = false + end + + def respond_to_missing? *args + @called = true + false + end + + def existing_method + end + end + + def test_method_by_respond_to_missing + bug_11211 = '[Bug #11211]' + obj = ExampleRespondToMissing.new + assert_equal("method", defined?(obj.existing_method), bug_11211) + assert_equal(false, obj.called, bug_11211) + assert_equal(nil, defined?(obj.non_existing_method), bug_11211) + assert_equal(true, obj.called, bug_11211) + end end Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r50737 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/