summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-17 15:55:50 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-17 15:55:50 +0000
commit5d3b8d0d5491096a10ae332db759b01c89a10f9d (patch)
tree5bf2615cc84589180661ef048f88e9eaa500173e
parentdb0f86030891ee91fb2e2b116dcc05bb3bcc019e (diff)
downloadruby-5d3b8d0d5491096a10ae332db759b01c89a10f9d.tar.gz
merge revision(s) r49322: [Backport #10753]
* vm_method.c (check_definition): Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined? should not use refinements. [ruby-core:67656] [Bug #10753] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_refinement.rb75
-rw-r--r--version.h6
-rw-r--r--vm_method.c2
4 files changed, 85 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a51c72272..6efce93db2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Mar 18 00:32:08 2015 Seiei Higa <hanachin@gmail.com>
+
+ * vm_method.c (check_definition): Module#public_method_defined?,
+ Module#private_method_defined?, Module#protected_method_defined?
+ should not use refinements. [ruby-core:67656] [Bug #10753]
+
Tue Mar 10 02:40:11 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* thread.c: Improve documentation for Thread#value
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 98bf9c6027..f34a7deb54 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1206,6 +1206,81 @@ class TestRefinement < Test::Unit::TestCase
end;
end
+ def test_refined_method_defined
+ assert_separately([], <<-"end;")
+ bug10753 = '[ruby-core:67656] [Bug #10753]'
+
+ c = Class.new do
+ def refined_public; end
+ def refined_protected; end
+ def refined_private; end
+
+ public :refined_public
+ protected :refined_protected
+ private :refined_private
+ end
+
+ m = Module.new do
+ refine(c) do
+ def refined_public; end
+ def refined_protected; end
+ def refined_private; end
+
+ public :refined_public
+ protected :refined_protected
+ private :refined_private
+ end
+ end
+
+ using m
+
+ assert_equal(true, c.public_method_defined?(:refined_public), bug10753)
+ assert_equal(false, c.public_method_defined?(:refined_protected), bug10753)
+ assert_equal(false, c.public_method_defined?(:refined_private), bug10753)
+
+ assert_equal(false, c.protected_method_defined?(:refined_public), bug10753)
+ assert_equal(true, c.protected_method_defined?(:refined_protected), bug10753)
+ assert_equal(false, c.protected_method_defined?(:refined_private), bug10753)
+
+ assert_equal(false, c.private_method_defined?(:refined_public), bug10753)
+ assert_equal(false, c.private_method_defined?(:refined_protected), bug10753)
+ assert_equal(true, c.private_method_defined?(:refined_private), bug10753)
+ end;
+ end
+
+ def test_undefined_refined_method_defined
+ assert_separately([], <<-"end;")
+ bug10753 = '[ruby-core:67656] [Bug #10753]'
+
+ c = Class.new
+
+ m = Module.new do
+ refine(c) do
+ def undefined_refined_public; end
+ def undefined_refined_protected; end
+ def undefined_refined_private; end
+ public :undefined_refined_public
+ protected :undefined_refined_protected
+ private :undefined_refined_private
+ end
+ end
+
+ using m
+
+ assert_equal(false, c.public_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.public_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.public_method_defined?(:undefined_refined_private), bug10753)
+
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.protected_method_defined?(:undefined_refined_private), bug10753)
+
+ assert_equal(false, c.private_method_defined?(:undefined_refined_public), bug10753)
+ assert_equal(false, c.private_method_defined?(:undefined_refined_protected), bug10753)
+ assert_equal(false, c.private_method_defined?(:undefined_refined_private), bug10753)
+ end;
+ end
+
private
def eval_using(mod, s)
diff --git a/version.h b/version.h
index 2798b80d5d..6173b28f34 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.5"
-#define RUBY_RELEASE_DATE "2015-03-10"
-#define RUBY_PATCHLEVEL 312
+#define RUBY_RELEASE_DATE "2015-03-18"
+#define RUBY_PATCHLEVEL 313
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 18
#include "ruby/version.h"
diff --git a/vm_method.c b/vm_method.c
index 3748e92679..c084d52e84 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1044,7 +1044,7 @@ check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex)
const rb_method_entry_t *me;
ID id = rb_check_id(&mid);
if (!id) return Qfalse;
- me = rb_method_entry(mod, id, 0);
+ me = rb_method_entry_without_refinements(mod, id, 0);
if (me) {
if (VISI_CHECK(me->flag, noex))
return Qtrue;