From 7de7245b3357d99f252606deef2134c7aa5ef1ee Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 24 Jan 2020 12:29:54 -0800 Subject: [PATCH] Fixed local method 'this' inside mixins --- IDEHelper/Compiler/BfExprEvaluator.cpp | 8 ++++++-- IDEHelper/Compiler/BfModule.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 8ec2297a..8e4f3f4c 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -12196,17 +12196,21 @@ void BfExprEvaluator::CheckLocalMethods(BfAstNode* targetSrc, BfTypeInstance* ty } } else - { + { BfLocalMethod* matchedLocalMethod = NULL; BfLocalMethod* localMethod = NULL; if (checkMethodState->mLocalMethodMap.TryGetValue(methodName, &localMethod)) { + auto typeInst = mModule->mCurTypeInstance; + if (checkMethodState->mMixinState != NULL) + typeInst = checkMethodState->mMixinState->mMixinMethodInstance->GetOwner(); + while (localMethod != NULL) { auto methodDef = mModule->GetLocalMethodDef(localMethod); if (methodDef->mMethodType == methodType) { - methodMatcher.CheckMethod(mModule->mCurTypeInstance, methodDef, true); + methodMatcher.CheckMethod(typeInst, methodDef, true); if (methodMatcher.mBestMethodDef == methodDef) matchedLocalMethod = localMethod; } diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 4bd4d8f7..9f62af34 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -17844,6 +17844,11 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth auto callerMethodState = mCurMethodState; auto typeInst = mCurTypeInstance; + + if (mCurMethodState->mMixinState != NULL) + { + typeInst = mCurMethodState->mMixinState->mMixinMethodInstance->GetOwner(); + } auto methodDef = GetLocalMethodDef(localMethod); @@ -18238,7 +18243,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth // We can only set mutating if our owning type is mutating if (localVar->mWrittenToId >= closureState.mCaptureStartAccessId) { - if (mCurTypeInstance->IsValueType()) + if (typeInst->IsValueType()) { if (rootMethodState->mMethodInstance->mMethodDef->mIsMutating) methodDef->mIsMutating = true;