mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed generic dependency issue with type aliases
This commit is contained in:
parent
f2237b4f97
commit
b9593348c7
2 changed files with 29 additions and 23 deletions
|
@ -1734,6 +1734,7 @@ public:
|
||||||
void ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance* typeInst, BfCEOnCompileKind onCompileKind);
|
void ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance* typeInst, BfCEOnCompileKind onCompileKind);
|
||||||
void DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers);
|
void DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers);
|
||||||
void DoCEEmit(BfMethodInstance* methodInstance);
|
void DoCEEmit(BfMethodInstance* methodInstance);
|
||||||
|
void DoPopulateType_SetGenericDependencies(BfTypeInstance* genericTypeInstance);
|
||||||
void DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
|
void DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
|
||||||
static BfModule* GetModuleFor(BfType* type);
|
static BfModule* GetModuleFor(BfType* type);
|
||||||
void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance);
|
void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance);
|
||||||
|
|
|
@ -1175,6 +1175,8 @@ void BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
||||||
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL))
|
if ((typeInstance->mCustomAttributes == NULL) && (typeDef->mTypeDeclaration != NULL) && (typeDef->mTypeDeclaration->mAttributes != NULL))
|
||||||
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, BfAttributeTargets_Alias);
|
typeInstance->mCustomAttributes = GetCustomAttributes(typeDef->mTypeDeclaration->mAttributes, BfAttributeTargets_Alias);
|
||||||
|
|
||||||
|
if (typeAlias->mGenericTypeInfo != NULL)
|
||||||
|
DoPopulateType_SetGenericDependencies(typeAlias);
|
||||||
// Fall through so generic params are populated in DoPopulateType
|
// Fall through so generic params are populated in DoPopulateType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2400,6 +2402,31 @@ void BfModule::DoCEEmit(BfMethodInstance* methodInstance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfModule::DoPopulateType_SetGenericDependencies(BfTypeInstance* genericTypeInstance)
|
||||||
|
{
|
||||||
|
// Add generic dependencies if needed
|
||||||
|
for (auto genericType : genericTypeInstance->mGenericTypeInfo->mTypeGenericArguments)
|
||||||
|
{
|
||||||
|
if (genericType->IsPrimitiveType())
|
||||||
|
genericType = GetWrappedStructType(genericType);
|
||||||
|
if (genericType != NULL)
|
||||||
|
{
|
||||||
|
AddDependency(genericType, genericTypeInstance, BfDependencyMap::DependencyFlag_TypeGenericArg);
|
||||||
|
BfLogSysM("Adding generic dependency of %p for type %p\n", genericType, genericTypeInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((genericTypeInstance->IsSpecializedType()) &&
|
||||||
|
(!genericTypeInstance->IsDelegateFromTypeRef()) &&
|
||||||
|
(!genericTypeInstance->IsFunctionFromTypeRef()))
|
||||||
|
{
|
||||||
|
// This ensures we rebuild the unspecialized type whenever the specialized type rebuilds. This is important
|
||||||
|
// for generic type binding
|
||||||
|
auto unspecializedTypeInstance = GetUnspecializedTypeInstance(genericTypeInstance);
|
||||||
|
BF_ASSERT(!unspecializedTypeInstance->IsUnspecializedTypeVariation());
|
||||||
|
mContext->mScratchModule->AddDependency(genericTypeInstance, unspecializedTypeInstance, BfDependencyMap::DependencyFlag_UnspecializedType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType)
|
void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType)
|
||||||
{
|
{
|
||||||
auto typeInstance = resolvedTypeRef->ToTypeInstance();
|
auto typeInstance = resolvedTypeRef->ToTypeInstance();
|
||||||
|
@ -2662,29 +2689,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
|
|
||||||
if (typeInstance->IsGenericTypeInstance())
|
if (typeInstance->IsGenericTypeInstance())
|
||||||
{
|
{
|
||||||
auto genericTypeInstance = (BfTypeInstance*)typeInstance;
|
DoPopulateType_SetGenericDependencies(typeInstance);
|
||||||
|
|
||||||
// Add generic dependencies if needed
|
|
||||||
for (auto genericType : genericTypeInstance->mGenericTypeInfo->mTypeGenericArguments)
|
|
||||||
{
|
|
||||||
if (genericType->IsPrimitiveType())
|
|
||||||
genericType = GetWrappedStructType(genericType);
|
|
||||||
if (genericType != NULL)
|
|
||||||
{
|
|
||||||
AddDependency(genericType, genericTypeInstance, BfDependencyMap::DependencyFlag_TypeGenericArg);
|
|
||||||
BfLogSysM("Adding generic dependency of %p for type %p\n", genericType, genericTypeInstance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((genericTypeInstance->IsSpecializedType()) &&
|
|
||||||
(!genericTypeInstance->IsDelegateFromTypeRef()) &&
|
|
||||||
(!genericTypeInstance->IsFunctionFromTypeRef()))
|
|
||||||
{
|
|
||||||
// This ensures we rebuild the unspecialized type whenever the specialized type rebuilds. This is important
|
|
||||||
// for generic type binding
|
|
||||||
auto unspecializedTypeInstance = GetUnspecializedTypeInstance(genericTypeInstance);
|
|
||||||
BF_ASSERT(!unspecializedTypeInstance->IsUnspecializedTypeVariation());
|
|
||||||
mContext->mScratchModule->AddDependency(genericTypeInstance, unspecializedTypeInstance, BfDependencyMap::DependencyFlag_UnspecializedType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue