mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Fix for new function/delegate casting
This commit is contained in:
parent
384863ae32
commit
ca814fe695
1 changed files with 40 additions and 41 deletions
|
@ -9532,18 +9532,18 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
|
||||||
|
|
||||||
// Function->Function and Delegate->Delegate where type is compatible but not exact
|
// Function->Function and Delegate->Delegate where type is compatible but not exact
|
||||||
if (((typedVal.mType->IsDelegate()) || (typedVal.mType->IsFunction())) &&
|
if (((typedVal.mType->IsDelegate()) || (typedVal.mType->IsFunction())) &&
|
||||||
|
(typedVal.mType != toType) && // Don't bother to check for exact match, let CastToValue handle this
|
||||||
((typedVal.mType->IsDelegate()) == (toType->IsDelegate())) &&
|
((typedVal.mType->IsDelegate()) == (toType->IsDelegate())) &&
|
||||||
((typedVal.mType->IsFunction()) == (toType->IsFunction())))
|
((typedVal.mType->IsFunction()) == (toType->IsFunction())))
|
||||||
{
|
{
|
||||||
auto fromDelegateType = (BfDelegateType*)typedVal.mType->ToTypeInstance();
|
auto fromTypeInst = typedVal.mType->ToTypeInstance();
|
||||||
auto toDelegateType = (BfDelegateType*)toType;
|
auto toTypeInst = toType->ToTypeInstance();
|
||||||
|
|
||||||
if (fromDelegateType->mReturnType == toDelegateType->mReturnType)
|
auto fromMethodInst = GetRawMethodByName(fromTypeInst, "Invoke", -1, true);
|
||||||
{
|
auto toMethodInst = GetRawMethodByName(toTypeInst, "Invoke", -1, true);
|
||||||
auto fromMethodInst = GetRawMethodByName(fromDelegateType, "Invoke");
|
|
||||||
auto toMethodInst = GetRawMethodByName(toDelegateType, "Invoke");
|
|
||||||
|
|
||||||
if ((fromMethodInst->mMethodDef->mCallingConvention == toMethodInst->mMethodDef->mCallingConvention) &&
|
if ((fromMethodInst != NULL) && (toMethodInst != NULL) &&
|
||||||
|
(fromMethodInst->mMethodDef->mCallingConvention == toMethodInst->mMethodDef->mCallingConvention) &&
|
||||||
(fromMethodInst->mReturnType == toMethodInst->mReturnType) &&
|
(fromMethodInst->mReturnType == toMethodInst->mReturnType) &&
|
||||||
(fromMethodInst->GetParamCount() == toMethodInst->GetParamCount()))
|
(fromMethodInst->GetParamCount() == toMethodInst->GetParamCount()))
|
||||||
{
|
{
|
||||||
|
@ -9584,7 +9584,6 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Struct truncate
|
// Struct truncate
|
||||||
if ((typedVal.mType->IsStruct()) && (toType->IsStruct()))
|
if ((typedVal.mType->IsStruct()) && (toType->IsStruct()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue