summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 06:24:25 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 06:24:25 +0000
commit134967e5b1f29d4dbb4f0c35f582d328f3eaf9e7 (patch)
tree65773626ec4f09261c7d16938392b4e084d44efd
parent84ec88a2319cfe716212d62f70bc10e855c2d2aa (diff)
merge revision(s) 62725: [Backport #14604]
Fix setting method visibility on method wrapped with prepend Ignore prepended modules when looking for already defined methods on a class to set the visibility on. [Fix GH-1834] From: Dylan Thacker-Smith <Dylan.Smith@shopify.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--test/ruby/test_module.rb19
-rw-r--r--version.h2
-rw-r--r--vm_method.c5
4 files changed, 33 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 12f61d9128..a8e3b8a795 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Mar 28 15:24:15 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ Fix setting method visibility on method wrapped with prepend
+
+ Ignore prepended modules when looking for already defined methods on a
+ class to set the visibility on.
+ [Fix GH-1834]
+
+ From: Dylan Thacker-Smith Dylan.Smith@shopify.com
+
Thu Mar 28 15:02:43 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
resolv.rb: close socket
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index b155ad7206..df40be3db0 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1864,6 +1864,25 @@ class TestModule < Test::Unit::TestCase
end;
end
+ def test_prepend_private_super
+ wrapper = Module.new do
+ def wrapped
+ super + 1
+ end
+ end
+
+ klass = Class.new do
+ prepend wrapper
+
+ def wrapped
+ 1
+ end
+ private :wrapped
+ end
+
+ assert_equal(2, klass.new.wrapped)
+ end
+
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)
diff --git a/version.h b/version.h
index 5d755f456d..a47a684c15 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.7"
#define RUBY_RELEASE_DATE "2018-03-28"
-#define RUBY_PATCHLEVEL 446
+#define RUBY_PATCHLEVEL 447
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 3
diff --git a/vm_method.c b/vm_method.c
index bb08ce64af..e6a8e51fa0 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1029,8 +1029,9 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
{
rb_method_entry_t *me;
VALUE defined_class;
+ VALUE origin_class = RCLASS_ORIGIN(klass);
- me = search_method(klass, name, &defined_class);
+ me = search_method(origin_class, name, &defined_class);
if (!me && RB_TYPE_P(klass, T_MODULE)) {
me = search_method(rb_cObject, name, &defined_class);
}
@@ -1043,7 +1044,7 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
if (METHOD_ENTRY_VISI(me) != visi) {
rb_vm_check_redefinition_opt_method(me, klass);
- if (klass == defined_class || RCLASS_ORIGIN(klass) == defined_class) {
+ if (klass == defined_class || origin_class == defined_class) {
METHOD_ENTRY_VISI_SET(me, visi);
if (me->def->type == VM_METHOD_TYPE_REFINED && me->def->body.refined.orig_me) {