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

Handled SetupNullConditional generic param cases

This commit is contained in:
Brian Fiete 2021-06-19 13:09:42 -07:00
parent d998fe2229
commit 74861b17a3

View file

@ -18865,7 +18865,26 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok
if (opResult) if (opResult)
thisValue = opResult; thisValue = opResult;
//TODO: But make null conditional work for Nullable types if (thisValue.mType->IsGenericParam())
{
bool isValid = false;
auto genericParams = mModule->GetGenericParamInstance((BfGenericParamType*)thisValue.mType);
if (genericParams->mTypeConstraint != NULL)
{
if ((genericParams->mTypeConstraint->IsNullable()) ||
(genericParams->mTypeConstraint->IsPointer()) ||
(genericParams->mTypeConstraint->IsObjectOrInterface()))
isValid = true;
}
if ((genericParams->mGenericParamFlags & (BfGenericParamFlag_Var | BfGenericParamFlag_StructPtr | BfGenericParamFlag_Class)) != 0)
isValid = true;
if (isValid)
return thisValue;
}
if (thisValue.mType->IsNullable()) if (thisValue.mType->IsNullable())
{ {
// Success // Success