mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Merge pull request #2206 from Fusioon/fix-iface-defer
Fix defer on interface methods
This commit is contained in:
commit
1a1c0daf76
2 changed files with 14 additions and 1 deletions
|
@ -7125,7 +7125,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
|
||||||
|
|
||||||
if (mDeferCallData != NULL)
|
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);
|
mModule->AddDeferredCall(BfModuleMethodInstance(methodInstance, mDeferCallData->mFuncAlloca), irArgs, mDeferCallData->mScopeAlloc, mDeferCallData->mRefNode, bypassVirtual, false, true);
|
||||||
else
|
else
|
||||||
mModule->AddDeferredCall(BfModuleMethodInstance(methodInstance, func), irArgs, mDeferCallData->mScopeAlloc, mDeferCallData->mRefNode, bypassVirtual);
|
mModule->AddDeferredCall(BfModuleMethodInstance(methodInstance, func), irArgs, mDeferCallData->mScopeAlloc, mDeferCallData->mRefNode, bypassVirtual);
|
||||||
|
|
|
@ -161,6 +161,7 @@ namespace Tests
|
||||||
|
|
||||||
interface ITest
|
interface ITest
|
||||||
{
|
{
|
||||||
|
void TestFunc();
|
||||||
static void Func();
|
static void Func();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +179,8 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public static int sVal;
|
public static int sVal;
|
||||||
|
|
||||||
|
public void TestFunc() => Func();
|
||||||
|
|
||||||
public static void Func()
|
public static void Func()
|
||||||
{
|
{
|
||||||
sVal = 123;
|
sVal = 123;
|
||||||
|
@ -189,6 +192,12 @@ namespace Tests
|
||||||
if (func != null)
|
if (func != null)
|
||||||
defer:: func.Invoke();
|
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)
|
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.sVal = 0;
|
||||||
Zoop.TestDefer();
|
Zoop.TestDefer();
|
||||||
Test.Assert(Zoop.sVal == 123);
|
Test.Assert(Zoop.sVal == 123);
|
||||||
|
|
||||||
|
Zoop.sVal = 0;
|
||||||
|
Zoop.TestIFaceDefer();
|
||||||
|
Test.Assert(Zoop.sVal == 123);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue