mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added error for conflicting extension override methods
This commit is contained in:
parent
bc46807003
commit
9d9cd528da
1 changed files with 28 additions and 1 deletions
|
@ -22261,6 +22261,8 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
|
|||
{
|
||||
if ((methodDef->mIsOverride) && (mCurTypeInstance->mTypeDef->mIsCombinedPartial))
|
||||
{
|
||||
bool takeover = false;
|
||||
|
||||
mCurTypeInstance->mTypeDef->PopulateMemberSets();
|
||||
BfMethodDef* nextMethod = NULL;
|
||||
BfMemberSetEntry* entry = NULL;
|
||||
|
@ -22273,6 +22275,28 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
|
|||
|
||||
if (checkMethod == methodDef)
|
||||
continue;
|
||||
if (checkMethod->mIsOverride)
|
||||
{
|
||||
auto checkMethodInstance = mCurTypeInstance->mMethodInstanceGroups[checkMethod->mIdx].mDefault;
|
||||
if (checkMethodInstance == NULL)
|
||||
continue;
|
||||
if (checkMethodInstance->mIRFunction == prevFunc)
|
||||
{
|
||||
BfAstNode* refNode = methodDef->GetRefNode();
|
||||
if (auto propertyMethodDeclaration = methodDef->GetPropertyMethodDeclaration())
|
||||
refNode = propertyMethodDeclaration->mPropertyDeclaration->mVirtualSpecifier;
|
||||
else if (auto methodDeclaration = methodDef->GetMethodDeclaration())
|
||||
refNode = methodDeclaration->mVirtualSpecifier;
|
||||
|
||||
auto error = Fail(StrFormat("Conflicting extension override method '%s'", MethodToString(mCurMethodInstance).c_str()), refNode);
|
||||
if (error != NULL)
|
||||
mCompiler->mPassInstance->MoreInfo("See previous override", checkMethod->GetRefNode());
|
||||
|
||||
takeover = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkMethod->mIsExtern)
|
||||
continue;
|
||||
auto checkMethodInstance = mCurTypeInstance->mMethodInstanceGroups[checkMethod->mIdx].mDefault;
|
||||
|
@ -22281,8 +22305,11 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
|
|||
if (!CompareMethodSignatures(checkMethodInstance, mCurMethodInstance))
|
||||
continue;
|
||||
// Take over function
|
||||
mCurMethodInstance->mIRFunction = prevFunc;
|
||||
takeover = true;
|
||||
}
|
||||
|
||||
if (takeover)
|
||||
mCurMethodInstance->mIRFunction = prevFunc;
|
||||
|
||||
if (!mCurMethodInstance->mIRFunction)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue