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

Fixed dependency issue with type lookups

This commit is contained in:
Brian Fiete 2020-03-27 06:47:26 -07:00
parent 9a5308b19e
commit 0720b9ad1a
3 changed files with 10 additions and 3 deletions

View file

@ -822,6 +822,9 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
return; return;
} }
// We need to verify lookups before we rebuild the type, because a type lookup change needs to count as a TypeDataChanged
VerifyTypeLookups(typeInst);
if (typeInst->mRevision != mCompiler->mRevision) if (typeInst->mRevision != mCompiler->mRevision)
{ {
BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInst, mCompiler->mRevision); BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInst, mCompiler->mRevision);
@ -2069,7 +2072,7 @@ void BfContext::UpdateRevisedTypes()
} }
void BfContext::VerifyTypeLookups(BfTypeInstance* typeInst) void BfContext::VerifyTypeLookups(BfTypeInstance* typeInst)
{ {
for (auto& lookupEntryPair : typeInst->mLookupResults) for (auto& lookupEntryPair : typeInst->mLookupResults)
{ {
BfTypeLookupEntry& lookupEntry = lookupEntryPair.mKey; BfTypeLookupEntry& lookupEntry = lookupEntryPair.mKey;
@ -2104,7 +2107,10 @@ void BfContext::VerifyTypeLookups(BfTypeInstance* typeInst)
} }
if (isDirty) if (isDirty)
{ {
// Clear lookup results to avoid infinite recursion
typeInst->mLookupResults.Clear();
// We need to treat this lookup as if it changed the whole type signature // We need to treat this lookup as if it changed the whole type signature
TypeDataChanged(typeInst, true); TypeDataChanged(typeInst, true);
TypeMethodSignaturesChanged(typeInst); TypeMethodSignaturesChanged(typeInst);

View file

@ -17673,6 +17673,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
if (resultType->IsNullable()) if (resultType->IsNullable())
{ {
auto elementType = resultType->GetUnderlyingType(); auto elementType = resultType->GetUnderlyingType();
mModule->PopulateType(elementType);
if (elementType->IsValuelessType()) if (elementType->IsValuelessType())
{ {
mModule->mBfIRBuilder->PopulateType(resultType); mModule->mBfIRBuilder->PopulateType(resultType);

View file

@ -3350,7 +3350,7 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
{ {
BF_ASSERT(typeInstance->mVirtualMethodTableSize >= (int)typeInstance->mVirtualMethodTable.size()); BF_ASSERT(typeInstance->mVirtualMethodTableSize >= (int)typeInstance->mVirtualMethodTable.size());
} }
} }
// Add new interfaces // Add new interfaces
for (int iFaceIdx = 0; iFaceIdx < (int)typeInstance->mInterfaces.size(); iFaceIdx++) for (int iFaceIdx = 0; iFaceIdx < (int)typeInstance->mInterfaces.size(); iFaceIdx++)