Fix up implict class/static methods
This commit is contained in:
parent
429c699c00
commit
8e80e04a33
@ -1622,8 +1622,8 @@ static void classBody(struct GlobalState * state, size_t blockWidth) {
|
||||
static struct CompilerSpecialMethod { const char * name; int type; } compilerSpecialMethods[] = {
|
||||
{"__init__", TYPE_INIT},
|
||||
{"__class_getitem__", TYPE_CLASSMETHOD},
|
||||
{"__init_subclass__", TYPE_CLASSMETHOD},
|
||||
{"__new__", TYPE_STATIC},
|
||||
{"__prepare__", TYPE_CLASSMETHOD},
|
||||
{NULL,0}
|
||||
};
|
||||
|
||||
|
@ -82,6 +82,21 @@ KRK_StaticMethod(type,__new__) {
|
||||
|
||||
/* Now copy the values over */
|
||||
krk_tableAddAll(&nspace->entries, &_class->methods);
|
||||
|
||||
KrkValue tmp;
|
||||
|
||||
if (krk_tableGet_fast(&_class->methods, S("__class_getitem__"), &tmp) && IS_CLOSURE(tmp)) {
|
||||
AS_CLOSURE(tmp)->obj.flags |= KRK_OBJ_FLAGS_FUNCTION_IS_CLASS_METHOD;
|
||||
}
|
||||
|
||||
if (krk_tableGet_fast(&_class->methods, S("__init_subclass__"), &tmp) && IS_CLOSURE(tmp)) {
|
||||
AS_CLOSURE(tmp)->obj.flags |= KRK_OBJ_FLAGS_FUNCTION_IS_CLASS_METHOD;
|
||||
}
|
||||
|
||||
if (krk_tableGet_fast(&_class->methods, S("__new__"), &tmp) && IS_CLOSURE(tmp)) {
|
||||
AS_CLOSURE(tmp)->obj.flags |= KRK_OBJ_FLAGS_FUNCTION_IS_STATIC_METHOD;
|
||||
}
|
||||
|
||||
krk_finalizeClass(_class);
|
||||
_callSetName(_class);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user