From 3c40f80f6d9e76d4584deca3f78a599c0daf2a69 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 14 Jul 2020 11:05:01 -0700 Subject: [PATCH] Made dot-constructors work with nullables --- IDEHelper/Compiler/BfExprEvaluator.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index f790b18a..991a0ad7 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -14035,15 +14035,23 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m BfResolveArgFlags resolveArgsFlags = BfResolveArgFlag_DeferParamEval; ResolveArgValues(argValues, resolveArgsFlags); - if ((mReceivingValue != NULL) && (mReceivingValue->mType == mExpectingType) && (mReceivingValue->IsAddr())) + auto expectingType = mExpectingType; + if (expectingType->IsNullable()) + { + auto underlyingType = expectingType->GetUnderlyingType(); + if (underlyingType->IsTypeInstance()) + expectingType = underlyingType; + } + + if ((mReceivingValue != NULL) && (mReceivingValue->mType == expectingType) && (mReceivingValue->IsAddr())) { mResult = *mReceivingValue; mReceivingValue = NULL; } else - mResult = BfTypedValue(mModule->CreateAlloca(mExpectingType), mExpectingType, BfTypedValueKind_TempAddr); - MatchConstructor(target, methodBoundExpr, mResult, mExpectingType->ToTypeInstance(), argValues, false, false); - mModule->ValidateAllocation(mExpectingType, invocationExpr->mTarget); + mResult = BfTypedValue(mModule->CreateAlloca(expectingType), expectingType, BfTypedValueKind_TempAddr); + MatchConstructor(target, methodBoundExpr, mResult, expectingType->ToTypeInstance(), argValues, false, false); + mModule->ValidateAllocation(expectingType, invocationExpr->mTarget); return; }