mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Added stricter 'this' type check for generic function binding
This commit is contained in:
parent
6029315ff6
commit
a8610ed711
1 changed files with 23 additions and 6 deletions
|
@ -10751,12 +10751,29 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr)
|
||||||
result = mModule->mBfIRBuilder->CreatePtrToInt(funcValue, BfTypeCode_IntPtr);
|
result = mModule->mBfIRBuilder->CreatePtrToInt(funcValue, BfTypeCode_IntPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((bindResult.mOrigTarget) && (bindResult.mOrigTarget.mType->IsGenericParam()) && (bindResult.mMethodInstance->GetOwner()->IsInterface()))
|
|
||||||
{
|
|
||||||
result = mModule->mBfIRBuilder->GetFakeVal();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ((bindResult.mOrigTarget) && (bindResult.mOrigTarget.mType->IsGenericParam()) && (bindResult.mMethodInstance->GetOwner()->IsInterface()))
|
||||||
|
{
|
||||||
|
bool matching = true;
|
||||||
|
if (methodInstance->HasExplicitThis())
|
||||||
|
{
|
||||||
|
auto thisType = methodInstance->GetParamType(0);
|
||||||
|
|
||||||
|
if (thisType->IsPointer())
|
||||||
|
thisType = thisType->GetUnderlyingType();
|
||||||
|
if (thisType->IsRef())
|
||||||
|
thisType = thisType->GetUnderlyingType();
|
||||||
|
|
||||||
|
matching = thisType == bindResult.mOrigTarget.mType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matching)
|
||||||
|
{
|
||||||
|
mResult = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), mExpectingType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
result = mModule->CastToFunction(delegateBindExpr->mTarget, bindResult.mOrigTarget, bindResult.mMethodInstance, mExpectingType);
|
result = mModule->CastToFunction(delegateBindExpr->mTarget, bindResult.mOrigTarget, bindResult.mMethodInstance, mExpectingType);
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue