diff options
-rw-r--r-- | class.c | 6 | ||||
-rw-r--r-- | internal/class.h | 3 |
2 files changed, 5 insertions, 4 deletions
@@ -700,7 +700,6 @@ class_alloc(VALUE flags, VALUE klass) RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj); RCLASS_SET_REFINED_CLASS((VALUE)obj, Qnil); - RCLASS_SET_ALLOCATOR((VALUE)obj, 0); RCLASS_SET_SUBCLASSES((VALUE)obj, anchor); @@ -1044,7 +1043,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig) RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(METACLASS_OF(clone), (VALUE)clone); } - RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig)); + if (BUILTIN_TYPE(clone) == T_CLASS) { + RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig)); + } copy_tables(clone, orig); if (RCLASS_M_TBL(orig)) { struct clone_method_arg arg; @@ -1085,7 +1086,6 @@ rb_mod_init_copy(VALUE clone, VALUE orig) rb_class_set_super(prev_clone_p, clone_p); prev_clone_p = clone_p; RCLASS_SET_CONST_TBL(clone_p, RCLASS_CONST_TBL(p), false); - RCLASS_SET_ALLOCATOR(clone_p, RCLASS_ALLOCATOR(p)); if (RB_TYPE_P(clone, T_CLASS)) { RCLASS_SET_INCLUDER(clone_p, clone); } diff --git a/internal/class.h b/internal/class.h index 15530b8842..4a3e0afafb 100644 --- a/internal/class.h +++ b/internal/class.h @@ -667,7 +667,8 @@ RCLASS_ALLOCATOR(VALUE klass) static inline void RCLASS_SET_ALLOCATOR(VALUE klass, rb_alloc_func_t allocator) { - assert(!RCLASS_SINGLETON_P(klass)); + RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS)); + RUBY_ASSERT(!RCLASS_SINGLETON_P(klass)); RCLASS_EXT_PRIME(klass)->as.class.allocator = allocator; // Allocator is set only on the initial definition } |