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

Fixed GetGenericTypeParamInstance with extensions

This commit is contained in:
Brian Fiete 2022-05-25 15:03:06 -07:00
parent 0c34e62df2
commit da29789bd6
3 changed files with 12 additions and 1 deletions

View file

@ -8891,7 +8891,8 @@ BfGenericParamInstance* BfModule::GetGenericTypeParamInstance(int genericParamId
if (genericTypeInst->mGenericTypeInfo->mGenericExtensionInfo != NULL) if (genericTypeInst->mGenericTypeInfo->mGenericExtensionInfo != NULL)
{ {
auto activeTypeDef = GetActiveTypeDef(NULL, true); auto activeTypeDef = GetActiveTypeDef(NULL, true);
if ((activeTypeDef->mTypeDeclaration != genericTypeInst->mTypeDef->mTypeDeclaration) && (activeTypeDef->IsExtension())) if ((activeTypeDef->mTypeDeclaration != genericTypeInst->mTypeDef->mTypeDeclaration) && (activeTypeDef->IsExtension()) &&
(genericTypeInst->mTypeDef->ContainsPartial(activeTypeDef)))
{ {
BfTypeDef* lookupTypeDef = activeTypeDef; BfTypeDef* lookupTypeDef = activeTypeDef;
while (lookupTypeDef->mNestDepth > genericTypeInst->mTypeDef->mNestDepth) while (lookupTypeDef->mNestDepth > genericTypeInst->mTypeDef->mNestDepth)

View file

@ -986,6 +986,15 @@ void BfTypeDef::ReportMemory(MemReporter* memReporter)
memReporter->AddVec(mDirectAllocNodes, false); memReporter->AddVec(mDirectAllocNodes, false);
} }
bool BfTypeDef::ContainsPartial(BfTypeDef* partialTypeDef)
{
if (partialTypeDef->mPartialIdx < 0)
return false;
if (partialTypeDef->mPartialIdx >= mPartials.mSize)
return false;
return mPartials[partialTypeDef->mPartialIdx] == partialTypeDef;
}
bool BfTypeDef::NameEquals(BfTypeDef* otherTypeDef) bool BfTypeDef::NameEquals(BfTypeDef* otherTypeDef)
{ {
if (mName != otherTypeDef->mName) if (mName != otherTypeDef->mName)

View file

@ -1211,6 +1211,7 @@ public:
BfMethodDef* GetMethodByName(const StringImpl& name, int paramCount = -1); BfMethodDef* GetMethodByName(const StringImpl& name, int paramCount = -1);
BfFieldDef* GetFieldByName(const StringImpl& name); BfFieldDef* GetFieldByName(const StringImpl& name);
bool HasAutoProperty(BfPropertyDeclaration* propertyDeclaration); bool HasAutoProperty(BfPropertyDeclaration* propertyDeclaration);
bool ContainsPartial(BfTypeDef* partialTypeDef);
String GetAutoPropertyName(BfPropertyDeclaration* propertyDeclaration); String GetAutoPropertyName(BfPropertyDeclaration* propertyDeclaration);
BfAstNode* GetRefNode(); BfAstNode* GetRefNode();