From 363990a105ca7088a257b4563fdd2442b952305b Mon Sep 17 00:00:00 2001 From: ZZYZX Date: Thu, 16 Feb 2017 02:31:20 +0200 Subject: [PATCH] Class abstractness should be inherited --- src/scripting/thingdef.cpp | 2 +- src/scripting/zscript/zcc_compile.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index d0b7df449..5b842ce07 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -194,7 +194,7 @@ PFunction *FindClassMemberFunction(PStruct *selfcls, PStruct *funccls, FName nam { sc.Message(MSG_ERROR, "%s is not a member function of %s", name.GetChars(), selfcls->TypeName.GetChars()); } - else if (funcsym->Variants[0].Flags & VARF_Private && symtable != &funccls->Symbols) + else if ((funcsym->Variants[0].Flags & VARF_Private) && symtable != &funccls->Symbols) { // private access is only allowed if the symbol table belongs to the class in which the current function is being defined. sc.Message(MSG_ERROR, "%s is declared private and not accessible", symbol->SymbolName.GetChars()); diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index bd73fa06c..187e2f341 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -599,10 +599,9 @@ void ZCCCompiler::CreateClassTypes() } } if (c->Type() == nullptr) c->cls->Type = parent->FindClassTentative(c->NodeName()); - if (c->cls->Flags & ZCC_Abstract) - { + // [ZZ] if parent class is abstract, this one should be abstract as well - otherwise we can subclass Actor and be able to new() our subclass + if ((c->cls->Flags & ZCC_Abstract) || (parent && parent->ObjectFlags & OF_Abstract)) c->Type()->ObjectFlags |= OF_Abstract; - } c->Type()->bExported = true; // this class is accessible to script side type casts. (The reason for this flag is that types like PInt need to be skipped.) c->cls->Symbol = new PSymbolType(c->NodeName(), c->Type()); OutNamespace->Symbols.AddSymbol(c->cls->Symbol);