diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index e36dc52f..5f40ac99 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -11140,8 +11140,7 @@ void BfExprEvaluator::Visit(BfCastExpression* castExpr) bool BfExprEvaluator::IsExactMethodMatch(BfMethodInstance* methodA, BfMethodInstance* methodB, bool ignoreImplicitParams) { if (methodA->mReturnType != methodB->mReturnType) - return false; - + return false; int implicitParamCountA = methodA->GetImplicitParamCount(); if (methodA->HasExplicitThis()) implicitParamCountA++; @@ -11703,7 +11702,11 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr) } else { - if (!IsExactMethodMatch(methodInstance, bindMethodInstance, true)) + bool isExactMethodMatch = IsExactMethodMatch(methodInstance, bindMethodInstance, true); + if ((mExpectingType != NULL) && (mExpectingType->IsFunction()) && (methodInstance->mMethodDef->mIsMutating != bindMethodInstance->mMethodDef->mIsMutating)) + isExactMethodMatch = false; + + if (!isExactMethodMatch) { if (bindResult.mCheckedMultipleMethods) { @@ -11711,8 +11714,8 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr) mModule->TypeToString(delegateTypeInstance).c_str()), delegateBindExpr->mTarget); } else - { - mModule->Fail(StrFormat("Method '%s' does not match %s '%s'", mModule->MethodToString(bindMethodInstance).c_str(), bindTypeName, + { + mModule->Fail(StrFormat("Method '%s' does not match %s '%s'", mModule->MethodToString(bindMethodInstance, (BfMethodNameFlags)(BfMethodNameFlag_IncludeReturnType | BfMethodNameFlag_IncludeMut)).c_str(), bindTypeName, mModule->TypeToString(delegateTypeInstance).c_str()), delegateBindExpr->mTarget); } mResult = BfTypedValue(); @@ -11732,7 +11735,7 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr) } bool hasIncompatibleCallingConventions = !mModule->mSystem->IsCompatibleCallingConvention(methodInstance->mCallingConvention, bindMethodInstance->mCallingConvention); - + auto _GetInvokeMethodName = [&]() { String methodName = "Invoke$"; @@ -11806,11 +11809,14 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr) if (result) { - String methodName = _GetInvokeMethodName(); + String methodName = _GetInvokeMethodName(); SizedArray irParamTypes; BfIRType irReturnType; - bindMethodInstance->GetIRFunctionInfo(mModule, irReturnType, irParamTypes); + methodInstance->GetIRFunctionInfo(mModule, irReturnType, irParamTypes); + + int thisFuncParamIdx = methodInstance->GetThisIdx(); + int thisBindParamIdx = methodInstance->GetThisIdx(); auto prevActiveFunction = mModule->mBfIRBuilder->GetActiveFunction(); auto prevInsertBlock = mModule->mBfIRBuilder->GetInsertBlock(); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 0036da17..1d8a28b2 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -10524,7 +10524,7 @@ bool BfModule::HasMixin(BfTypeInstance* typeInstance, const StringImpl& methodNa } StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodNameFlags methodNameFlags, BfTypeVector* typeGenericArgs, BfTypeVector* methodGenericArgs) -{ +{ auto methodDef = methodInst->mMethodDef; bool allowResolveGenericParamNames = ((methodNameFlags & BfMethodNameFlag_ResolveGenericParamNames) != 0); @@ -10769,8 +10769,16 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName if (accessorString.length() != 0) { - methodName += " " + accessorString; + methodName += " "; + methodName += accessorString; } + + if ((methodNameFlags & BfMethodNameFlag_IncludeMut) != 0) + { + if ((methodDef->mIsMutating) && (methodInst->GetOwner()->IsValueType())) + methodName += " mut"; + } + return methodName; } diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 7b85a000..c99a4e77 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -1298,15 +1298,6 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType, } } -// if ((paramIdx == 0) && (GetParamName(0) == "this") && (checkType->IsPointer())) -// { -// // We don't actually pass a this pointer for mut methods in valueless structs -// auto underlyingType = checkType->GetUnderlyingType(); -// module->PopulateType(underlyingType, BfPopulateType_Data); -// if (underlyingType->IsValuelessType()) -// continue; -// } - if (checkType->CanBeValuelessType()) module->PopulateType(checkType, BfPopulateType_Data); if ((checkType->IsValuelessType()) && (!checkType->IsMethodRef())) diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.h b/IDEHelper/Compiler/BfResolvedTypeUtils.h index 0f7a6fa9..7563609d 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.h +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.h @@ -61,7 +61,8 @@ enum BfMethodNameFlags : uint8 BfMethodNameFlag_ResolveGenericParamNames = 1, BfMethodNameFlag_OmitTypeName = 2, BfMethodNameFlag_IncludeReturnType = 4, - BfMethodNameFlag_OmitParams = 8 + BfMethodNameFlag_OmitParams = 8, + BfMethodNameFlag_IncludeMut = 0x10 }; enum BfGetMethodInstanceFlags : uint16