diff options
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -730,8 +730,12 @@ VALUE rb_obj_alloc(klass) VALUE klass; { - VALUE obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0); + VALUE obj; + if (FL_TEST(klass, FL_SINGLETON)) { + rb_raise(rb_eTypeError, "can't create instance of virtual class"); + } + obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0); if (rb_obj_class(obj) != rb_class_real(klass)) { rb_raise(rb_eTypeError, "wrong instance allocation"); } @@ -743,14 +747,9 @@ static VALUE rb_class_allocate_instance(klass) VALUE klass; { - if (FL_TEST(klass, FL_SINGLETON)) { - rb_raise(rb_eTypeError, "can't create instance of virtual class"); - } - else { - NEWOBJ(obj, struct RObject); - OBJSETUP(obj, klass, T_OBJECT); - return (VALUE)obj; - } + NEWOBJ(obj, struct RObject); + OBJSETUP(obj, klass, T_OBJECT); + return (VALUE)obj; } VALUE |