1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-15 14:54:09 +02:00

Handle 'func?.Invoke()'

This commit is contained in:
Brian Fiete 2025-01-18 06:48:33 -08:00
parent a1cd01cd3d
commit 910f560380
2 changed files with 14 additions and 3 deletions

View file

@ -979,10 +979,17 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
canUseMethod &= addNonStatic; canUseMethod &= addNonStatic;
} }
else else
{
if (typeInst->IsFunction())
{
canUseMethod = true;
}
else
{ {
canUseMethod &= (CHECK_STATIC(methodDef->mIsStatic) && canUseMethod &= (CHECK_STATIC(methodDef->mIsStatic) &&
(mModule->CheckProtection(protectionCheckFlags, typeInst, methodDef->mDeclaringType->mProject, methodDef->mProtection, startType))); (mModule->CheckProtection(protectionCheckFlags, typeInst, methodDef->mDeclaringType->mProject, methodDef->mProtection, startType)));
} }
}
if (canUseMethod) if (canUseMethod)
{ {
AddMethod(typeInst, methodDef, NULL, methodDef->GetMethodDeclaration(), methodDef->mName, filter); AddMethod(typeInst, methodDef, NULL, methodDef->GetMethodDeclaration(), methodDef->mName, filter);

View file

@ -21803,7 +21803,7 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok
{ {
// Success // Success
} }
else if ((thisValue.mType->IsPointer()) || (thisValue.mType->IsObjectOrInterface())) else if ((thisValue.mType->IsPointer()) || (thisValue.mType->IsObjectOrInterface()) || (thisValue.mType->IsFunction()))
{ {
// Also good // Also good
} }
@ -21863,6 +21863,10 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok
thisValue = BfTypedValue(valuePtr, elementType, true); thisValue = BfTypedValue(valuePtr, elementType, true);
} }
} }
else if (thisValue.mType->IsFunction())
{
isNotNull = mModule->mBfIRBuilder->CreateCmpNE(thisValue.mValue, mModule->GetDefaultValue(thisValue.mType));
}
else else
isNotNull = mModule->mBfIRBuilder->CreateIsNotNull(thisValue.mValue); isNotNull = mModule->mBfIRBuilder->CreateIsNotNull(thisValue.mValue);
BfIRBlock notNullBB = mModule->mBfIRBuilder->CreateBlock("nullCond.notNull"); BfIRBlock notNullBB = mModule->mBfIRBuilder->CreateBlock("nullCond.notNull");