1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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_3@55402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2016-06-13 18:33:28 +00:00
parent 84b8954d0d
commit cd1e32f7ff
4 changed files with 32 additions and 6 deletions

View file

@ -1,3 +1,11 @@
Tue Jun 14 03:25:14 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.
Tue Jun 14 03:15:54 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_exec_getargs): honor the expected argument types

View file

@ -863,10 +863,6 @@ defineclass
rb_obj_class(super));
}
if (super == Qnil) {
super = rb_cObject;
}
vm_check_if_namespace(cbase);
/* find klass */
@ -879,7 +875,7 @@ defineclass
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class", rb_id2str(id));
}
if (super != rb_cObject) {
if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags)) {
VALUE tmp;
tmp = rb_class_real(RCLASS_SUPER(klass));
@ -890,6 +886,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));

View file

@ -375,6 +375,25 @@ class TestClass < Test::Unit::TestCase
}
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 = []

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.2"
#define RUBY_RELEASE_DATE "2016-06-14"
#define RUBY_PATCHLEVEL 126
#define RUBY_PATCHLEVEL 127
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 6