summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-18 22:54:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-18 22:54:25 +0000
commit125b62e76d97fd9483c9e15313f80c43a8c1a213 (patch)
tree83750302fec59fc52a83ab168178b04b5d2ed4e4 /object.c
parentc4d77cb4adaae2bab9aa015c9a0528f0abf07bbd (diff)
downloadruby-125b62e76d97fd9483c9e15313f80c43a8c1a213.tar.gz
* object.c (rb_obj_clone): singleton class should be attached
singleton object to. a patch by Satoshi Shiba <shiba AT rvm.jp> at [ruby-dev:44460]. [Bug #5274] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/object.c b/object.c
index 5d21709a5d..3a7265b31d 100644
--- a/object.c
+++ b/object.c
@@ -273,12 +273,17 @@ VALUE
rb_obj_clone(VALUE obj)
{
VALUE clone;
+ VALUE singleton;
if (rb_special_const_p(obj)) {
rb_raise(rb_eTypeError, "can't clone %s", rb_obj_classname(obj));
}
clone = rb_obj_alloc(rb_obj_class(obj));
- RBASIC(clone)->klass = rb_singleton_class_clone(obj);
+ singleton = rb_singleton_class_clone(obj);
+ RBASIC(clone)->klass = singleton;
+ if (FL_TEST(singleton, FL_SINGLETON)) {
+ rb_singleton_class_attached(singleton, clone);
+ }
RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT) | FL_TEST(clone, FL_UNTRUSTED)) & ~(FL_FREEZE|FL_FINALIZE|FL_MARK);
init_copy(clone, obj);
rb_funcall(clone, id_init_clone, 1, obj);