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

Fixed lookup for 'new' generic conformance

This commit is contained in:
Brian Fiete 2020-06-23 11:52:58 -07:00
parent d31c9df8ac
commit 8169587b4c
2 changed files with 24 additions and 7 deletions

View file

@ -766,7 +766,7 @@ BfType * BfContext::FindTypeById(int typeId)
void BfContext::AddTypeToWorkList(BfType* type) void BfContext::AddTypeToWorkList(BfType* type)
{ {
BF_ASSERT(!mAssertOnPopulateType); //BF_ASSERT(!mAssertOnPopulateType);
BF_ASSERT((type->mRebuildFlags & BfTypeRebuildFlag_InTempPool) == 0); BF_ASSERT((type->mRebuildFlags & BfTypeRebuildFlag_InTempPool) == 0);
if ((type->mRebuildFlags & BfTypeRebuildFlag_AddedToWorkList) == 0) if ((type->mRebuildFlags & BfTypeRebuildFlag_AddedToWorkList) == 0)

View file

@ -6865,10 +6865,26 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS
{ {
if (checkTypeInst->IsObjectOrStruct()) if (checkTypeInst->IsObjectOrStruct())
{ {
auto ctorClear = GetRawMethodByName(checkTypeInst, "__BfCtor", 0); checkTypeInst->mTypeDef->PopulateMemberSets();
if (ctorClear->mMethodDef->mProtection == BfProtection_Public) BfMemberSetEntry* entry = NULL;
canAlloc = true; BfMethodDef* checkMethodDef = NULL;
else if ((ctorClear->mMethodDef->mProtection == BfProtection_Protected) && (mCurTypeInstance != NULL)) checkTypeInst->mTypeDef->mMethodSet.TryGetWith(String("__BfCtor"), &entry);
if (entry != NULL)
checkMethodDef = (BfMethodDef*)entry->mMemberDef;
bool hadProtected = false;
while (checkMethodDef != NULL)
{
if (checkMethodDef->mProtection == BfProtection_Public)
{
canAlloc = true;
break;
}
if (checkMethodDef->mProtection == BfProtection_Protected)
hadProtected = true;
checkMethodDef = checkMethodDef->mNextWithSameName;
}
if ((!canAlloc) && (hadProtected) && (mCurTypeInstance != NULL))
canAlloc = TypeIsSubTypeOf(mCurTypeInstance, checkTypeInst, false); canAlloc = TypeIsSubTypeOf(mCurTypeInstance, checkTypeInst, false);
} }
} }
@ -9024,8 +9040,9 @@ BfMethodInstance* BfModule::GetRawMethodInstanceAtIdx(BfTypeInstance* typeInstan
{ {
if (!mCompiler->mIsResolveOnly) if (!mCompiler->mIsResolveOnly)
{ {
BF_ASSERT((methodGroup.mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference) || (methodGroup.mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingDecl)); BF_ASSERT((methodGroup.mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference) || (methodGroup.mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingDecl) || (typeInstance->mTypeFailed));
methodGroup.mOnDemandKind = BfMethodOnDemandKind_Decl_AwaitingDecl; if ((methodGroup.mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference) || (methodGroup.mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingDecl))
methodGroup.mOnDemandKind = BfMethodOnDemandKind_Decl_AwaitingDecl;
// Get it from the owning module so we don't create a reference prematurely... // Get it from the owning module so we don't create a reference prematurely...
auto declModule = typeInstance->mModule; auto declModule = typeInstance->mModule;