1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Fixed default ctor base ctor calling when base has extensions

This commit is contained in:
Brian Fiete 2022-02-22 08:14:17 -08:00
parent c91c81f77d
commit c2490278fa

View file

@ -17597,7 +17597,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
bool hadCtorWithAllDefaults = false; bool hadCtorWithAllDefaults = false;
bool isHiddenGenerated = (methodDeclaration == NULL) && (methodDef->mProtection == BfProtection_Hidden); bool isHiddenGenerated = (methodDeclaration == NULL) && (methodDef->mProtection == BfProtection_Hidden);
for (int pass = 0; pass < 2; pass++) for (int pass = 0; pass < 2; pass++)
{ {
baseType->mTypeDef->PopulateMemberSets(); baseType->mTypeDef->PopulateMemberSets();
@ -17605,7 +17605,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
BfMethodDef* checkMethodDef = NULL; BfMethodDef* checkMethodDef = NULL;
baseType->mTypeDef->mMethodSet.TryGetWith(String("__BfCtor"), &entry); baseType->mTypeDef->mMethodSet.TryGetWith(String("__BfCtor"), &entry);
if (entry != NULL) if (entry != NULL)
checkMethodDef = (BfMethodDef*)entry->mMemberDef; checkMethodDef = (BfMethodDef*)entry->mMemberDef;
while (checkMethodDef != NULL) while (checkMethodDef != NULL)
{ {
@ -17617,19 +17617,25 @@ void BfModule::EmitCtorBody(bool& skipBody)
if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults)) if ((checkMethodDef->mMethodDeclaration == NULL) && (pass == 1) && (!hadCtorWithAllDefaults))
allowMethod = true; 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; if (matchedMethod != NULL)
{
// Has multiple matched methods - can happen from extensions
matchedMethod = NULL;
break;
}
matchedMethod = checkMethodDef;
} }
else if (isHiddenGenerated) 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;
} }
} }
checkMethodDef = checkMethodDef->mNextWithSameName; checkMethodDef = checkMethodDef->mNextWithSameName;
} }