mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed default base ctor issues
This commit is contained in:
parent
c48c292f78
commit
e6344c02b1
2 changed files with 21 additions and 14 deletions
|
@ -5176,7 +5176,22 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
||||||
if ((autoComplete != NULL) && (prevNode != NULL))
|
if ((autoComplete != NULL) && (prevNode != NULL))
|
||||||
autoComplete->CheckEmptyStart(prevNode, wantType);
|
autoComplete->CheckEmptyStart(prevNode, wantType);
|
||||||
|
|
||||||
BfError* error = mModule->Fail(StrFormat("Not enough parameters specified, expected %d more.", methodInstance->GetParamCount() - paramIdx), refNode);
|
BfError* error = NULL;
|
||||||
|
|
||||||
|
if (mModule->mParentNodeEntry != NULL)
|
||||||
|
{
|
||||||
|
if (auto ctorDeclaration = BfNodeDynCast<BfConstructorDeclaration>(mModule->mParentNodeEntry->mNode))
|
||||||
|
{
|
||||||
|
if (ctorDeclaration->mInitializer == NULL)
|
||||||
|
{
|
||||||
|
error = mModule->Fail(StrFormat("No parameterless constructor is available for base class. Consider calling base constructor '%s'.",
|
||||||
|
mModule->MethodToString(methodInstance).c_str()), refNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
if ((error != NULL) && (methodInstance->mMethodDef->mMethodDeclaration != NULL))
|
||||||
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See method declaration"), methodInstance->mMethodDef->GetRefNode());
|
mModule->mCompiler->mPassInstance->MoreInfo(StrFormat("See method declaration"), methodInstance->mMethodDef->GetRefNode());
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
|
@ -14408,8 +14408,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
(baseType->mTypeDef != mCompiler->mBfObjectTypeDef))
|
(baseType->mTypeDef != mCompiler->mBfObjectTypeDef))
|
||||||
{
|
{
|
||||||
// Try to find a ctor without any params first
|
// Try to find a ctor without any params first
|
||||||
BfMethodDef* matchedMethod = NULL;
|
BfMethodDef* matchedMethod = NULL;
|
||||||
bool hadCtorWithAllDefaults = false;
|
|
||||||
|
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
{
|
{
|
||||||
|
@ -14422,22 +14421,13 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
|
|
||||||
while (checkMethodDef != NULL)
|
while (checkMethodDef != NULL)
|
||||||
{
|
{
|
||||||
bool allowMethod = checkMethodDef->mProtection > BfProtection_Private;
|
bool allowMethod = checkMethodDef->mProtection > BfProtection_Private;
|
||||||
// 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->mMethodType == BfMethodType_Ctor) && (!checkMethodDef->mIsStatic) && (allowMethod))
|
||||||
{
|
{
|
||||||
if (checkMethodDef->mParams.size() == 0)
|
if (checkMethodDef->mParams.size() == 0)
|
||||||
{
|
{
|
||||||
matchedMethod = checkMethodDef;
|
matchedMethod = checkMethodDef;
|
||||||
}
|
}
|
||||||
else if ((checkMethodDef->mParams[0]->mParamDeclaration != NULL) && (checkMethodDef->mParams[0]->mParamDeclaration->mInitializer != NULL))
|
|
||||||
{
|
|
||||||
if (pass == 0)
|
|
||||||
hadCtorWithAllDefaults = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMethodDef = checkMethodDef->mNextWithSameName;
|
checkMethodDef = checkMethodDef->mNextWithSameName;
|
||||||
|
@ -14481,6 +14471,8 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
|
|
||||||
if (targetType != NULL)
|
if (targetType != NULL)
|
||||||
{
|
{
|
||||||
|
BfAutoParentNodeEntry autoParentNodeEntry(this, methodDeclaration);
|
||||||
|
|
||||||
auto autoComplete = mCompiler->GetAutoComplete();
|
auto autoComplete = mCompiler->GetAutoComplete();
|
||||||
auto wasCapturingMethodInfo = (autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo);
|
auto wasCapturingMethodInfo = (autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo);
|
||||||
if ((autoComplete != NULL) && (ctorDeclaration != NULL) && (ctorDeclaration->mInitializer != NULL))
|
if ((autoComplete != NULL) && (ctorDeclaration != NULL) && (ctorDeclaration->mInitializer != NULL))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue