From c12a5acfc2b0a97beaff67513f695555f668a4b9 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 22 Dec 2003 12:15:34 +0000 Subject: * class.c (rb_mod_init_copy): always copy singleton class. [ruby-dev:22325] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++++++- class.c | 3 +++ object.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 85b520c9f..ac0ad5d5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ +Mon Dec 22 21:15:29 2003 Nobuyoshi Nakada + + * class.c (rb_mod_init_copy): always copy singleton class. + [ruby-dev:22325] + Mon Dec 22 20:44:36 2003 akira yamada * lib/uri/generic.rb (URI::Generic#route_from): accepts urls which has no host-part. - + * test/uri/test_generic.rb (TestGeneric::test_route): added a test. Mon Dec 22 20:38:44 2003 Nobuyoshi Nakada diff --git a/class.c b/class.c index 29fe34a91..35b2c985a 100644 --- a/class.c +++ b/class.c @@ -63,6 +63,9 @@ rb_mod_init_copy(clone, orig) VALUE clone, orig; { rb_obj_init_copy(clone, orig); + if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { + RBASIC(clone)->klass = rb_singleton_class_clone(orig); + } RCLASS(clone)->super = RCLASS(orig)->super; if (RCLASS(orig)->iv_tbl) { ID id; diff --git a/object.c b/object.c index fda641027..174d8ccfc 100644 --- a/object.c +++ b/object.c @@ -1662,6 +1662,7 @@ Init_Object() rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0); rb_define_method(rb_cClass, "new", rb_class_new_instance, -1); rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1); + rb_define_method(rb_cClass, "initialize_copy", rb_class_init_copy, 1); rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0); rb_define_alloc_func(rb_cClass, rb_class_s_alloc); rb_undef_method(rb_cClass, "extend_object"); -- cgit