diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 5172c176..546a6689 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -4566,17 +4566,11 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu (!isSkipCall)) { bool skipMutCheck = false; - if (prevBindResult.mPrevVal != NULL) + if ((prevBindResult.mPrevVal != NULL) && (prevBindResult.mPrevVal->mSkipMutCheck)) { // If we are binding a delegate, then we will end up making a copy of the target anyway // so we don't need to do a mutability check skipMutCheck = true; -// auto bindResult = prevBindResult.mPrevVal; -// if ((bindResult->mOrigTarget) && -// ((bindResult->mOrigTarget.mType->IsVar()) || (bindResult->mOrigTarget.mType->IsPointer()))) -// { -// skipMutCheck = true; -// } } PushThis(targetSrc, target, moduleMethodInstance.mMethodInstance, irArgs, skipMutCheck); @@ -8104,6 +8098,7 @@ bool BfExprEvaluator::CanBindDelegate(BfDelegateBindExpression* delegateBindExpr methodGenericArguments = &delegateBindExpr->mGenericArgs->mGenericArgs; BfFunctionBindResult bindResult; + bindResult.mSkipMutCheck = true; // Allow operating on copies mFunctionBindResult = &bindResult; SetAndRestoreValue ignoreError(mModule->mIgnoreErrors, true); DoInvocation(delegateBindExpr->mTarget, delegateBindExpr, args, methodGenericArguments); @@ -8505,6 +8500,7 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr) } BfFunctionBindResult bindResult; + bindResult.mSkipMutCheck = true; // Allow operating on copies mFunctionBindResult = &bindResult; DoInvocation(delegateBindExpr->mTarget, delegateBindExpr, args, methodGenericArguments); mFunctionBindResult = NULL; diff --git a/IDEHelper/Compiler/BfExprEvaluator.h b/IDEHelper/Compiler/BfExprEvaluator.h index 5a4d363c..90d4ff88 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.h +++ b/IDEHelper/Compiler/BfExprEvaluator.h @@ -219,6 +219,7 @@ public: BfIRValue mFunc; BfMethodInstance* mMethodInstance; bool mSkipThis; + bool mSkipMutCheck; bool mWantsArgs; bool mCheckedMultipleMethods; SizedArray mIRArgs; @@ -227,6 +228,7 @@ public: BfFunctionBindResult() { mMethodInstance = NULL; + mSkipMutCheck = false; mWantsArgs = false; mSkipThis = false; mCheckedMultipleMethods = false;