ruby-changes:50767
From: usa <ko1@a...>
Date: Wed, 28 Mar 2018 15:24:31 +0900 (JST)
Subject: [ruby-changes:50767] usa:r62950 (ruby_2_3): merge revision(s) 62725: [Backport #14604]
usa 2018-03-28 15:24:25 +0900 (Wed, 28 Mar 2018) New Revision: 62950 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62950 Log: 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@s...> Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/test/ruby/test_module.rb branches/ruby_2_3/version.h branches/ruby_2_3/vm_method.c Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 62949) +++ ruby_2_3/ChangeLog (revision 62950) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Thu Mar 28 15:24:15 2018 Nobuyoshi Nakada <nobu@r...> + + 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@s... + Thu Mar 28 15:02:43 2018 Nobuyoshi Nakada <nobu@r...> resolv.rb: close socket Index: ruby_2_3/test/ruby/test_module.rb =================================================================== --- ruby_2_3/test/ruby/test_module.rb (revision 62949) +++ ruby_2_3/test/ruby/test_module.rb (revision 62950) @@ -1864,6 +1864,25 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_module.rb#L1864 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) Index: ruby_2_3/vm_method.c =================================================================== --- ruby_2_3/vm_method.c (revision 62949) +++ ruby_2_3/vm_method.c (revision 62950) @@ -1029,8 +1029,9 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm_method.c#L1029 { 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, r https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm_method.c#L1044 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) { Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 62949) +++ ruby_2_3/version.h (revision 62950) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #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 Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 62949) +++ ruby_2_3 (revision 62950) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62725 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/