From 1c8a2a8e446c5be6b743e3a363fb3b2d1b9d4c84 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 10 Mar 2020 08:27:48 -0700 Subject: [PATCH] Fixed cast issue in resolveOnly --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index d12e84cc..fe2424d2 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -9139,18 +9139,25 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp if (!castedFromValue) return BfIRValue(); + BfTypedValue operatorOut; if (ignoreWrites) - return mBfIRBuilder->GetFakeVal(); - - BfModuleMethodInstance moduleMethodInstance = GetMethodInstance(opMethodInstance->GetOwner(), opMethodInstance->mMethodDef, BfTypeVector()); - - SizedArray args; - exprEvaluator.PushArg(castedFromValue, args); - auto operatorOut = exprEvaluator.CreateCall(moduleMethodInstance.mMethodInstance, mCompiler->IsSkippingExtraResolveChecks() ? BfIRValue() : moduleMethodInstance.mFunc, false, args); - if ((operatorOut.mType != NULL) && (operatorOut.mType->IsSelf())) { - BF_ASSERT(IsInGeneric()); - operatorOut = GetDefaultTypedValue(opMethodSrcType); + if (opMethodInstance->mReturnType == toType) + return mBfIRBuilder->GetFakeVal(); + operatorOut = GetDefaultTypedValue(opMethodInstance->mReturnType); + } + else + { + BfModuleMethodInstance moduleMethodInstance = GetMethodInstance(opMethodInstance->GetOwner(), opMethodInstance->mMethodDef, BfTypeVector()); + + SizedArray args; + exprEvaluator.PushArg(castedFromValue, args); + operatorOut = exprEvaluator.CreateCall(moduleMethodInstance.mMethodInstance, mCompiler->IsSkippingExtraResolveChecks() ? BfIRValue() : moduleMethodInstance.mFunc, false, args); + if ((operatorOut.mType != NULL) && (operatorOut.mType->IsSelf())) + { + BF_ASSERT(IsInGeneric()); + operatorOut = GetDefaultTypedValue(opMethodSrcType); + } } return CastToValue(srcNode, operatorOut, toType, castFlags, resultFlags);