Skip to content
Permalink
Browse files

Merge pull request #677 from krekoten/class_new

Class#new superclass check and naming
  • Loading branch information
alex committed May 3, 2013
2 parents d7b5f06 + 476051e commit 43639bae81bbfd05f293ea9a04459fe832c2a16f
Showing with 13 additions and 11 deletions.
  1. +0 −8 spec/tags/core/class/new_tags.txt
  2. +1 −2 spec/tags/core/module/name_tags.txt
  3. +2 −0 topaz/interpreter.py
  4. +10 −1 topaz/objects/classobject.py

This file was deleted.

@@ -1,7 +1,6 @@
fails:Module#name is nil for a nested module created with the module keyword
fails:Module#name is set when assigning to a constant
fails:Module#name is not modified when assigning to a new constant after it has been accessed
fails:Module#name is set with a conditional assignment to a nested constant
fails:Module#name is set with a conditional assignment to a constant
fails:Module#name preserves the encoding in which the class was defined
fails:Module#name is set when the anonymous outer module name is set
fails:Module#name is nil when assigned to a constant in an anonymous module
@@ -202,6 +202,8 @@ def STORE_CONSTANT(self, space, bytecode, frame, pc, idx):
w_value = frame.pop()
w_scope = frame.pop()
space.set_const(w_scope, name, w_value)
if isinstance(w_value, W_ModuleObject) and w_value.name is None:
w_value.name = space.buildname(name, w_scope)
frame.push(w_value)

def DEFINED_CONSTANT(self, space, bytecode, frame, pc, idx):
@@ -84,7 +84,16 @@ def method_removed(self, space, w_name):
@classdef.singleton_method("allocate")
def singleton_method_allocate(self, space, w_superclass=None):
if w_superclass is not None:
assert isinstance(w_superclass, W_ClassObject)
if not isinstance(w_superclass, W_ClassObject):
raise space.error(
space.w_TypeError,
"superclass must be a Class (%s given)" % space.obj_to_s(space.getclass(w_superclass))
)
if w_superclass.is_singleton:
raise space.error(
space.w_TypeError,
"can't make subclass of singleton class"
)
else:
w_superclass = space.w_object
return space.newclass(None, w_superclass)

0 comments on commit 43639ba

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