mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Properly complains about hidden parameterless base ctor calling
This commit is contained in:
parent
2b0f7fb485
commit
7c44884cf0
2 changed files with 21 additions and 8 deletions
|
@ -5272,13 +5272,22 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
||||||
|
|
||||||
if (mModule->mParentNodeEntry != NULL)
|
if (mModule->mParentNodeEntry != NULL)
|
||||||
{
|
{
|
||||||
|
bool showCtorError = false;
|
||||||
|
|
||||||
if (auto ctorDeclaration = BfNodeDynCast<BfConstructorDeclaration>(mModule->mParentNodeEntry->mNode))
|
if (auto ctorDeclaration = BfNodeDynCast<BfConstructorDeclaration>(mModule->mParentNodeEntry->mNode))
|
||||||
{
|
{
|
||||||
if (ctorDeclaration->mInitializer == NULL)
|
if (ctorDeclaration->mInitializer == NULL)
|
||||||
{
|
showCtorError = true;
|
||||||
error = mModule->Fail(StrFormat("No parameterless constructor is available for base class. Consider calling base constructor '%s'.",
|
}
|
||||||
mModule->MethodToString(methodInstance).c_str()), refNode);
|
|
||||||
}
|
if (auto typerDecl = BfNodeDynCast<BfTypeDeclaration>(mModule->mParentNodeEntry->mNode))
|
||||||
|
showCtorError = true;
|
||||||
|
|
||||||
|
|
||||||
|
if (showCtorError)
|
||||||
|
{
|
||||||
|
error = mModule->Fail(StrFormat("No parameterless constructor is available for base class. Consider calling base constructor '%s'.",
|
||||||
|
mModule->MethodToString(methodInstance).c_str()), refNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14446,7 +14446,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
BfMethodDef* matchedMethod = NULL;
|
BfMethodDef* matchedMethod = NULL;
|
||||||
bool hadCtorWithAllDefaults = false;
|
bool hadCtorWithAllDefaults = false;
|
||||||
|
|
||||||
bool isGenerated = methodDeclaration == NULL;
|
bool isHiddenGenerated = (methodDeclaration == NULL) && (methodDef->mProtection == BfProtection_Hidden);
|
||||||
|
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
{
|
{
|
||||||
|
@ -14461,7 +14461,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
{
|
{
|
||||||
bool allowMethod = checkMethodDef->mProtection > BfProtection_Private;
|
bool allowMethod = checkMethodDef->mProtection > BfProtection_Private;
|
||||||
|
|
||||||
if (isGenerated)
|
if (isHiddenGenerated)
|
||||||
{
|
{
|
||||||
// Allow calling of the default base ctor if it is implicitly defined
|
// Allow calling of the default base ctor if it is implicitly defined
|
||||||
if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults))
|
if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults))
|
||||||
|
@ -14474,7 +14474,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
{
|
{
|
||||||
matchedMethod = checkMethodDef;
|
matchedMethod = checkMethodDef;
|
||||||
}
|
}
|
||||||
else if (isGenerated)
|
else if (isHiddenGenerated)
|
||||||
{
|
{
|
||||||
if ((checkMethodDef->mParams[0]->mParamDeclaration != NULL) && (checkMethodDef->mParams[0]->mParamDeclaration->mInitializer != NULL))
|
if ((checkMethodDef->mParams[0]->mParamDeclaration != NULL) && (checkMethodDef->mParams[0]->mParamDeclaration->mInitializer != NULL))
|
||||||
hadCtorWithAllDefaults = true;
|
hadCtorWithAllDefaults = true;
|
||||||
|
@ -14522,7 +14522,11 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
|
|
||||||
if (targetType != NULL)
|
if (targetType != NULL)
|
||||||
{
|
{
|
||||||
BfAutoParentNodeEntry autoParentNodeEntry(this, methodDeclaration);
|
BfAstNode* refNode = methodDeclaration;
|
||||||
|
if (refNode == NULL)
|
||||||
|
refNode = typeDef->mTypeDeclaration;
|
||||||
|
|
||||||
|
BfAutoParentNodeEntry autoParentNodeEntry(this, refNode);
|
||||||
|
|
||||||
auto autoComplete = mCompiler->GetAutoComplete();
|
auto autoComplete = mCompiler->GetAutoComplete();
|
||||||
auto wasCapturingMethodInfo = (autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo);
|
auto wasCapturingMethodInfo = (autoComplete != NULL) && (autoComplete->mIsCapturingMethodMatchInfo);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue