summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/object.c b/object.c
index c9fc29d5bd..602634ea24 100644
--- a/object.c
+++ b/object.c
@@ -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