From 935d5bd340817563cc946aa206835a93dedd967a Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 10 Jul 2022 16:58:34 -0400 Subject: [PATCH] Allow null conditional on generic param without warning --- IDEHelper/Compiler/BfExprEvaluator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 0a64071e..0d5658bb 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -21208,8 +21208,13 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok // Also good } else - { - mModule->Warn(0, StrFormat("Null conditional reference is unnecessary since value type '%s' can never be null", mModule->TypeToString(thisValue.mType).c_str()), dotToken); + { + bool canBeNull = false; + if (thisValue.mType->IsGenericParam()) + canBeNull = true; + + if (!canBeNull) + mModule->Warn(0, StrFormat("Null conditional reference is unnecessary since value type '%s' can never be null", mModule->TypeToString(thisValue.mType).c_str()), dotToken); return thisValue; }