summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/array.c b/array.c
index d8dc37195ca..f2089996e5f 100644
--- a/array.c
+++ b/array.c
@@ -680,9 +680,13 @@ static VALUE
rb_ary_dup(ary)
VALUE ary;
{
+ VALUE klass = CLASS_OF(ary);
VALUE dup;
- dup = rb_ary_s_create(RARRAY(ary)->len, RARRAY(ary)->ptr, CLASS_OF(ary));
+ while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = (VALUE)RCLASS(klass)->super;
+ }
+ dup = rb_ary_s_create(RARRAY(ary)->len, RARRAY(ary)->ptr, klass);
if (OBJ_TAINTED(ary)) OBJ_TAINT(dup);
return dup;
}