diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 06:54:56 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 06:54:56 +0000 |
commit | 7a25e90ee5174d975c44ed232258ff5c41a54a18 (patch) | |
tree | 9b95b15923af984a61c93ca05eac6ad1ab4c095d | |
parent | 1511ef08ef72e17f648599cf6fddc2ea6d17d27e (diff) |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | insns.def | 9 | ||||
-rw-r--r-- | test/ruby/test_class.rb | 19 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 32 insertions, 6 deletions
@@ -1,3 +1,11 @@ +Fri Jun 10 15:54:05 2016 Benoit Daloze <eregontp@gmail.com> + + * 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@mbf.nifty.com> * bignum.c: [DOC] Update result of 123456789 ** -2. @@ -925,10 +925,6 @@ defineclass rb_obj_classname(super)); } - if (super == Qnil) { - super = rb_cObject; - } - vm_check_if_namespace(cbase); /* find klass */ @@ -941,7 +937,7 @@ defineclass 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 } } 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)); diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index e17f56f913..e02a3d243d 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -358,6 +358,25 @@ class TestClass < Test::Unit::TestCase 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 = [] @@ -1,6 +1,6 @@ #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 |