Skip to content
Permalink
Browse files

Merge pull request #693 from krekoten/language_class

Class definition
  • Loading branch information
alex committed May 9, 2013
2 parents a91e4a6 + 8a3b122 commit e672004258b93e8e9605cd68e6ded23d2e8a1c0d
Showing with 8 additions and 2 deletions.
  1. +0 −2 spec/tags/language/class_tags.txt
  2. +8 −0 topaz/interpreter.py
@@ -1,3 +1 @@
fails:A class definition raises a TypeError if inheriting from a metaclass
fails:A class definition extending an object (sclass) can use return to cause the enclosing method to return
fails:Reopening a class raises a TypeError when superclasses mismatch
@@ -375,10 +375,18 @@ def BUILD_CLASS(self, space, bytecode, frame, pc):
"wrong argument type %s (expected Class)" % cls_name
)
assert isinstance(superclass, W_ClassObject)
if superclass.is_singleton:
raise space.error(space.w_TypeError, "can't make subclass of singleton class")
w_cls = space.newclass(name, superclass, w_scope=w_scope)
space.set_const(w_scope, name, w_cls)
elif not space.is_kind_of(w_cls, space.w_class):
raise space.error(space.w_TypeError, "%s is not a class" % name)
else:
assert isinstance(w_cls, W_ClassObject)
if superclass is not space.w_nil and w_cls.superclass is not superclass:
raise space.error(space.w_TypeError,
"superclass mismatch for class %s" % w_cls.name
)

frame.push(w_cls)

0 comments on commit e672004

Please sign in to comment.
You can’t perform that action at this time.