[前][次][番号順一覧][スレッド一覧]

ruby-changes:40723

From: usa <ko1@a...>
Date: Mon, 30 Nov 2015 21:34:33 +0900 (JST)
Subject: [ruby-changes:40723] usa:r52802 (ruby_2_1): merge revision(s) 50737: [Backport #11211]

usa	2015-11-30 21:34:23 +0900 (Mon, 30 Nov 2015)

  New Revision: 52802

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52802

  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_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/insns.def
    branches/ruby_2_1/test/ruby/test_defined.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 52801)
+++ ruby_2_1/ChangeLog	(revision 52802)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Mon Nov 30 21:29:57 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.
+
 Mon Nov 30 21:27:09 2015  NAKAMURA Usaku  <usa@r...>
 
 	* ext/digest/rmd160/rmd160.c: fixed commit mistake at r52797.
Index: ruby_2_1/insns.def
===================================================================
--- ruby_2_1/insns.def	(revision 52801)
+++ ruby_2_1/insns.def	(revision 52802)
@@ -738,15 +738,12 @@ defined https://github.com/ruby/ruby/blob/trunk/ruby_2_1/insns.def#L738
 	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_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 52801)
+++ ruby_2_1/version.h	(revision 52802)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.8"
 #define RUBY_RELEASE_DATE "2015-11-30"
-#define RUBY_PATCHLEVEL 427
+#define RUBY_PATCHLEVEL 428
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 11
Index: ruby_2_1/test/ruby/test_defined.rb
===================================================================
--- ruby_2_1/test/ruby/test_defined.rb	(revision 52801)
+++ ruby_2_1/test/ruby/test_defined.rb	(revision 52802)
@@ -209,4 +209,29 @@ class TestDefined < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_defined.rb#L209
   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_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r50737


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]