1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 12:02:21 +02:00

Fixed local method 'this' inside mixins

This commit is contained in:
Brian Fiete 2020-01-24 12:29:54 -08:00
parent ea0ccae3d5
commit 7de7245b33
2 changed files with 12 additions and 3 deletions

View file

@ -12201,12 +12201,16 @@ void BfExprEvaluator::CheckLocalMethods(BfAstNode* targetSrc, BfTypeInstance* ty
BfLocalMethod* localMethod = NULL; BfLocalMethod* localMethod = NULL;
if (checkMethodState->mLocalMethodMap.TryGetValue(methodName, &localMethod)) if (checkMethodState->mLocalMethodMap.TryGetValue(methodName, &localMethod))
{ {
auto typeInst = mModule->mCurTypeInstance;
if (checkMethodState->mMixinState != NULL)
typeInst = checkMethodState->mMixinState->mMixinMethodInstance->GetOwner();
while (localMethod != NULL) while (localMethod != NULL)
{ {
auto methodDef = mModule->GetLocalMethodDef(localMethod); auto methodDef = mModule->GetLocalMethodDef(localMethod);
if (methodDef->mMethodType == methodType) if (methodDef->mMethodType == methodType)
{ {
methodMatcher.CheckMethod(mModule->mCurTypeInstance, methodDef, true); methodMatcher.CheckMethod(typeInst, methodDef, true);
if (methodMatcher.mBestMethodDef == methodDef) if (methodMatcher.mBestMethodDef == methodDef)
matchedLocalMethod = localMethod; matchedLocalMethod = localMethod;
} }

View file

@ -17845,6 +17845,11 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
auto typeInst = mCurTypeInstance; auto typeInst = mCurTypeInstance;
if (mCurMethodState->mMixinState != NULL)
{
typeInst = mCurMethodState->mMixinState->mMixinMethodInstance->GetOwner();
}
auto methodDef = GetLocalMethodDef(localMethod); auto methodDef = GetLocalMethodDef(localMethod);
BfAstNode* body = NULL; BfAstNode* body = NULL;
@ -18238,7 +18243,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
// We can only set mutating if our owning type is mutating // We can only set mutating if our owning type is mutating
if (localVar->mWrittenToId >= closureState.mCaptureStartAccessId) if (localVar->mWrittenToId >= closureState.mCaptureStartAccessId)
{ {
if (mCurTypeInstance->IsValueType()) if (typeInst->IsValueType())
{ {
if (rootMethodState->mMethodInstance->mMethodDef->mIsMutating) if (rootMethodState->mMethodInstance->mMethodDef->mIsMutating)
methodDef->mIsMutating = true; methodDef->mIsMutating = true;