ruby-changes:43277
From: usa <ko1@a...>
Date: Fri, 10 Jun 2016 15:55:01 +0900 (JST)
Subject: [ruby-changes:43277] usa:r55351 (ruby_2_2): merge revision(s) 54970: [Backport #12367]
usa 2016-06-10 15:54:56 +0900 (Fri, 10 Jun 2016) New Revision: 55351 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55351 Log: merge revision(s) 54970: [Backport #12367] * insns.def (defineclass): Also raise an error when redeclaring the superclass of a class as Object and it has another superclass. [Bug #12367] [ruby-core:75446] * test/ruby/test_class.rb: test for above. Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/insns.def branches/ruby_2_2/test/ruby/test_class.rb branches/ruby_2_2/version.h Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 55350) +++ ruby_2_2/version.h (revision 55351) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.6" #define RUBY_RELEASE_DATE "2016-06-10" -#define RUBY_PATCHLEVEL 326 +#define RUBY_PATCHLEVEL 327 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 6 Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 55350) +++ ruby_2_2/ChangeLog (revision 55351) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Fri Jun 10 15:54:05 2016 Benoit Daloze <eregontp@g...> + + * insns.def (defineclass): Also raise an error when redeclaring the + superclass of a class as Object and it has another superclass. + [Bug #12367] [ruby-core:75446] + + * test/ruby/test_class.rb: test for above. + Fri Jun 10 15:46:24 2016 Kazuhiro NISHIYAMA <zn@m...> * bignum.c: [DOC] Update result of 123456789 ** -2. Index: ruby_2_2/insns.def =================================================================== --- ruby_2_2/insns.def (revision 55350) +++ ruby_2_2/insns.def (revision 55351) @@ -925,10 +925,6 @@ defineclass https://github.com/ruby/ruby/blob/trunk/ruby_2_2/insns.def#L925 rb_obj_classname(super)); } - if (super == Qnil) { - super = rb_cObject; - } - vm_check_if_namespace(cbase); /* find klass */ @@ -941,7 +937,7 @@ defineclass https://github.com/ruby/ruby/blob/trunk/ruby_2_2/insns.def#L937 rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id)); } - if (super != rb_cObject) { + if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags)) { VALUE tmp; tmp = rb_class_real(RCLASS_SUPER(klass)); @@ -952,6 +948,9 @@ defineclass https://github.com/ruby/ruby/blob/trunk/ruby_2_2/insns.def#L948 } } else { + if (!VM_DEFINECLASS_HAS_SUPERCLASS_P(flags)) { + super = rb_cObject; + } /* new class declaration */ klass = rb_define_class_id(id, super); rb_set_class_path_string(klass, cbase, rb_id2str(id)); Index: ruby_2_2/test/ruby/test_class.rb =================================================================== --- ruby_2_2/test/ruby/test_class.rb (revision 55350) +++ ruby_2_2/test/ruby/test_class.rb (revision 55351) @@ -358,6 +358,25 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_class.rb#L358 end end + define_method :test_invalid_reset_superclass do + class A; end + class SuperclassCannotBeReset < A + end + assert_equal A, SuperclassCannotBeReset.superclass + + assert_raise_with_message(TypeError, /superclass mismatch/) { + class SuperclassCannotBeReset < String + end + } + + assert_raise_with_message(TypeError, /superclass mismatch/, "[ruby-core:75446]") { + class SuperclassCannotBeReset < Object + end + } + + assert_equal A, SuperclassCannotBeReset.superclass + end + def test_cloned_singleton_method_added bug5283 = '[ruby-dev:44477]' added = [] Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r54970 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/