diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 4d269e34..df3a8ba6 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -5190,7 +5190,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu } } - if (error != NULL) + if (error == NULL) error = mModule->Fail(StrFormat("Not enough parameters specified, expected %d more.", methodInstance->GetParamCount() - paramIdx), refNode); if ((error != NULL) && (methodInstance->mMethodDef->mMethodDeclaration != NULL)) mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See method declaration"), methodInstance->mMethodDef->GetRefNode()); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index fe9ae167..c25d8d3e 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -14408,7 +14408,10 @@ void BfModule::EmitCtorBody(bool& skipBody) (baseType->mTypeDef != mCompiler->mBfObjectTypeDef)) { // Try to find a ctor without any params first - BfMethodDef* matchedMethod = NULL; + BfMethodDef* matchedMethod = NULL; + bool hadCtorWithAllDefaults = false; + + bool isGenerated = methodDeclaration == NULL; for (int pass = 0; pass < 2; pass++) { @@ -14421,13 +14424,26 @@ void BfModule::EmitCtorBody(bool& skipBody) while (checkMethodDef != NULL) { - bool allowMethod = checkMethodDef->mProtection > BfProtection_Private; + bool allowMethod = checkMethodDef->mProtection > BfProtection_Private; + + if (isGenerated) + { + // Allow calling of the default base ctor if it is implicitly defined + if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults)) + allowMethod = true; + } + if ((checkMethodDef->mMethodType == BfMethodType_Ctor) && (!checkMethodDef->mIsStatic) && (allowMethod)) { if (checkMethodDef->mParams.size() == 0) { matchedMethod = checkMethodDef; - } + } + else if (isGenerated) + { + if ((checkMethodDef->mParams[0]->mParamDeclaration != NULL) && (checkMethodDef->mParams[0]->mParamDeclaration->mInitializer != NULL)) + hadCtorWithAllDefaults = true; + } } checkMethodDef = checkMethodDef->mNextWithSameName;