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

Merge pull request #2206 from Fusioon/fix-iface-defer

Fix defer on interface methods
This commit is contained in:
Brian Fiete 2025-05-10 09:22:51 +02:00 committed by GitHub
commit 1a1c0daf76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -7125,7 +7125,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
if (mDeferCallData != NULL)
{
if (mDeferCallData->mFuncAlloca_Orig == func)
if ((func) && (mDeferCallData->mFuncAlloca_Orig == func))
mModule->AddDeferredCall(BfModuleMethodInstance(methodInstance, mDeferCallData->mFuncAlloca), irArgs, mDeferCallData->mScopeAlloc, mDeferCallData->mRefNode, bypassVirtual, false, true);
else
mModule->AddDeferredCall(BfModuleMethodInstance(methodInstance, func), irArgs, mDeferCallData->mScopeAlloc, mDeferCallData->mRefNode, bypassVirtual);

View file

@ -161,6 +161,7 @@ namespace Tests
interface ITest
{
void TestFunc();
static void Func();
}
@ -178,6 +179,8 @@ namespace Tests
{
public static int sVal;
public void TestFunc() => Func();
public static void Func()
{
sVal = 123;
@ -189,6 +192,12 @@ namespace Tests
if (func != null)
defer:: func.Invoke();
}
public static void TestIFaceDefer()
{
ITest itest = scope Zoop();
defer itest.TestFunc();
}
}
public static int UseFunc0<T>(function int (T this, float f) func, T a, float b)
@ -265,6 +274,10 @@ namespace Tests
Zoop.sVal = 0;
Zoop.TestDefer();
Test.Assert(Zoop.sVal == 123);
Zoop.sVal = 0;
Zoop.TestIFaceDefer();
Test.Assert(Zoop.sVal == 123);
}
}
}