1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +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

@ -18864,8 +18864,27 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok
auto opResult = PerformUnaryOperation_TryOperator(thisValue, NULL, BfUnaryOp_NullConditional, dotToken, BfUnaryOpFlag_None);
if (opResult)
thisValue = opResult;
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;
}
//TODO: But make null conditional work for Nullable types
if (thisValue.mType->IsNullable())
{
// Success