ruby-changes:50741
From: nagachika <ko1@a...>
Date: Sun, 25 Mar 2018 15:11:19 +0900 (JST)
Subject: [ruby-changes:50741] nagachika:r62918 (ruby_2_4): merge revision(s) 62725: [Backport #14604]
nagachika 2018-03-25 15:11:14 +0900 (Sun, 25 Mar 2018) New Revision: 62918 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62918 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_4/ Modified files: branches/ruby_2_4/test/ruby/test_module.rb branches/ruby_2_4/version.h branches/ruby_2_4/vm_method.c Index: ruby_2_4/vm_method.c =================================================================== --- ruby_2_4/vm_method.c (revision 62917) +++ ruby_2_4/vm_method.c (revision 62918) @@ -1057,8 +1057,9 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_method.c#L1057 { 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); } @@ -1071,7 +1072,7 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_method.c#L1072 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_4/version.h =================================================================== --- ruby_2_4/version.h (revision 62917) +++ ruby_2_4/version.h (revision 62918) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2018-03-25" -#define RUBY_PATCHLEVEL 287 +#define RUBY_PATCHLEVEL 288 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/test/ruby/test_module.rb =================================================================== --- ruby_2_4/test/ruby/test_module.rb (revision 62917) +++ ruby_2_4/test/ruby/test_module.rb (revision 62918) @@ -1876,6 +1876,25 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_module.rb#L1876 assert_raise(ArgumentError) { Module.new { prepend } } 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_4 =================================================================== --- ruby_2_4 (revision 62917) +++ ruby_2_4 (revision 62918) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r62725 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/