1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed late ctor hiding with extensions

This commit is contained in:
Brian Fiete 2024-12-02 14:34:51 -05:00
parent 124d191bab
commit b900477287
2 changed files with 23 additions and 12 deletions

View file

@ -1277,18 +1277,24 @@ void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
typeModule->PrepareForIRWriting(resolvedTypeRef->ToTypeInstance()); typeModule->PrepareForIRWriting(resolvedTypeRef->ToTypeInstance());
} }
else else
{ {
BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData)); if ((mCompiler->mCompileState == BfCompiler::CompileState_Unreified) || (mCompiler->mCompileState == BfCompiler::CompileState_VData))
{
FailInternal(StrFormat("Invalid late reification of type '%s'", TypeToString(resolvedTypeRef).c_str()));
}
else
{
BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData));
BfLogSysM("Queued reification of type %p in module %p in PopulateType\n", resolvedTypeRef, typeModule);
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 != mContext->mUnreifiedModule) && (typeModule != mContext->mScratchModule)); BF_ASSERT(!typeModule->mIsSpecialModule);
// This caused issues - we may need to reify a type and then request a method
BF_ASSERT(!typeModule->mIsSpecialModule); typeModule->mReifyQueued = true;
// This caused issues - we may need to reify a type and then request a method mContext->mReifyModuleWorkList.Add(typeModule);
typeModule->mReifyQueued = true; //typeModule->ReifyModule();
mContext->mReifyModuleWorkList.Add(typeModule); }
//typeModule->ReifyModule();
} }
} }
} }
@ -6244,12 +6250,16 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
// Generate all methods. Pass 0 // Generate all methods. Pass 0
for (auto methodDef : typeDef->mMethods) for (auto methodDef : typeDef->mMethods)
{ {
if ((methodDef->mMethodType == BfMethodType_Ctor) && (!methodDef->mIsStatic)) if ((methodDef->mMethodType == BfMethodType_Ctor) && (!methodDef->mIsStatic) && (!methodDef->mDeclaringType->IsExtension()))
{ {
if (methodDef->mMethodDeclaration == NULL) if (methodDef->mMethodDeclaration == NULL)
{
defaultCtor = methodDef; defaultCtor = methodDef;
}
else else
{
hasExplicitCtors = true; hasExplicitCtors = true;
}
} }
auto methodInstanceGroup = &typeInstance->mMethodInstanceGroups[methodDef->mIdx]; auto methodInstanceGroup = &typeInstance->mMethodInstanceGroups[methodDef->mIdx];

View file

@ -1924,7 +1924,8 @@ BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
{ {
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef); SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
mModule->PopulateType(checkInnerType, checkInnerType->IsValueType() ? BfPopulateType_Data : BfPopulateType_Declaration); if (checkInnerType->IsDataIncomplete())
mModule->PopulateType(checkInnerType, checkInnerType->IsValueType() ? BfPopulateType_Data : BfPopulateType_Declaration);
if (checkInnerType->mSize > unionSize) if (checkInnerType->mSize > unionSize)
unionSize = checkInnerType->mSize; unionSize = checkInnerType->mSize;