From c01f06089f233e74b9e4c0d41b395264da87062f Mon Sep 17 00:00:00 2001 From: charliesome Date: Thu, 13 Dec 2012 14:11:01 +0000 Subject: * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy * class.c (rb_class_init_copy): rename to class_init_copy_check, performs type checks on arguments to prevent reinitialization of initialized class [ruby-core:50869] [Bug #7557] * class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS * test/ruby/test_class.rb (class TestClass): related test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_class.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index a3384fa083..e3047ccd5f 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -270,4 +270,19 @@ class TestClass < Test::Unit::TestCase bug5274 = StrClone.new("[ruby-dev:44460]") assert_equal(bug5274, Marshal.load(Marshal.dump(bug5274))) end + + def test_cannot_reinitialize_class_with_initialize_copy # [ruby-core:50869] + assert_in_out_err([], <<-RUBY, ["Object"], []) + class Class + def initialize_copy(*); super; end + end + + class A; end + class B; end + + A.send(:initialize_copy, Class.new(B)) rescue nil + + p A.superclass + RUBY + end end -- cgit v1.2.3