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

Fixed improper generic method variation reification

This commit is contained in:
Brian Fiete 2020-05-25 14:12:53 -07:00
parent 8c2d65ca78
commit 42ae46390d
2 changed files with 25 additions and 14 deletions

View file

@ -11423,22 +11423,26 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
{
if ((mIsReified) && (!instModule->mIsReified))
{
if (!instModule->mReifyQueued)
if (!typeInst->IsUnspecializedTypeVariation())
{
BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData));
BfLogSysM("Queueing ReifyModule: %p\n", instModule);
mContext->mReifyModuleWorkList.Add(instModule);
instModule->mReifyQueued = true;
}
if (!instModule->mReifyQueued)
{
BF_ASSERT((instModule != mContext->mUnreifiedModule) && (instModule != mContext->mScratchModule));
BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData));
BfLogSysM("Queueing ReifyModule: %p\n", instModule);
mContext->mReifyModuleWorkList.Add(instModule);
instModule->mReifyQueued = true;
}
// This ensures that the method will actually be created when it gets reified
BfMethodSpecializationRequest* specializationRequest = mContext->mMethodSpecializationWorkList.Alloc();
specializationRequest->mFromModule = typeInst->mModule;
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
specializationRequest->mMethodDef = methodDef;
specializationRequest->mMethodGenericArguments = methodGenericArguments;
specializationRequest->mType = typeInst;
specializationRequest->mFlags = flags;
// This ensures that the method will actually be created when it gets reified
BfMethodSpecializationRequest* specializationRequest = mContext->mMethodSpecializationWorkList.Alloc();
specializationRequest->mFromModule = typeInst->mModule;
specializationRequest->mFromModuleRevision = typeInst->mModule->mRevision;
specializationRequest->mMethodDef = methodDef;
specializationRequest->mMethodGenericArguments = methodGenericArguments;
specializationRequest->mType = typeInst;
specializationRequest->mFlags = flags;
}
}
auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
@ -19307,6 +19311,11 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
if (methodDef->mMethodType == BfMethodType_Mixin)
methodInstance->mIsUnspecialized = true;
if (methodInstance->mIsUnspecialized)
{
//BF_ASSERT(methodInstance->mDeclModule == methodInstance->GetOwner()->mModule);
}
BfAutoComplete* bfAutocomplete = NULL;
if (mCompiler->mResolvePassData != NULL)
bfAutocomplete = mCompiler->mResolvePassData->mAutoComplete;

View file

@ -829,6 +829,8 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
BfLogSysM("Queued reification of type %p in module %p in PopulateType\n", resolvedTypeRef, typeModule);
BF_ASSERT((typeModule != mContext->mUnreifiedModule) && (typeModule != mContext->mScratchModule));
BF_ASSERT(!typeModule->mIsSpecialModule);
// This caused issues - we may need to reify a type and then request a method
typeModule->mReifyQueued = true;