1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed mangling issue with method overrides in extensions

This commit is contained in:
Brian Fiete 2020-11-16 07:36:34 -08:00
parent e2de5becab
commit 2e3880100b
3 changed files with 40 additions and 18 deletions

View file

@ -20248,8 +20248,32 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
{
if ((methodDef->mIsOverride) && (mCurTypeInstance->mTypeDef->mIsCombinedPartial))
{
BfLogSysM("Function collision from inner override erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
mBfIRBuilder->Func_SafeRename(prevFunc);
mCurTypeInstance->mTypeDef->PopulateMemberSets();
BfMethodDef* nextMethod = NULL;
BfMemberSetEntry* entry = NULL;
if (mCurTypeInstance->mTypeDef->mMethodSet.TryGet(BfMemberSetEntry(methodDef), &entry))
nextMethod = (BfMethodDef*)entry->mMemberDef;
while (nextMethod != NULL)
{
auto checkMethod = nextMethod;
nextMethod = nextMethod->mNextWithSameName;
if (checkMethod == methodDef)
continue;
auto checkMethodInstance = mCurTypeInstance->mMethodInstanceGroups[checkMethod->mIdx].mDefault;
if (checkMethodInstance == NULL)
continue;
if (!CompareMethodSignatures(checkMethodInstance, mCurMethodInstance))
continue;
// Take over function
mCurMethodInstance->mIRFunction = prevFunc;
}
if (!mCurMethodInstance->mIRFunction)
{
BfLogSysM("Function collision from inner override erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
mBfIRBuilder->Func_SafeRename(prevFunc);
}
}
else if (methodDef->mIsExtern)
{