1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Handle methodGenericArg dep for IsSpecializedByAutoCompleteMethod

This commit is contained in:
Brian Fiete 2022-08-26 06:02:07 -07:00
parent ae8ea6281d
commit c04d240210
2 changed files with 26 additions and 22 deletions

View file

@ -2991,32 +2991,35 @@ void BfMethodMatcher::TryDevirtualizeCall(BfTypedValue target, BfTypedValue* ori
while (checkTypeInst != NULL)
{
mModule->PopulateType(checkTypeInst, BfPopulateType_DataAndMethods);
for (auto&& iface : checkTypeInst->mInterfaces)
if (checkTypeInst->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotted)
{
//TODO: Why did we have this check? This caused Dictionary to not be able to devirtualize
// calls to TKey GetHashCode when TKey was from a user's project...
/*if (!checkTypeInst->IsTypeMemberAccessible(iface.mDeclaringType, activeTypeDef))
continue;*/
if (iface.mInterfaceType == mBestMethodTypeInstance)
for (auto&& iface : checkTypeInst->mInterfaces)
{
if (bestIFaceEntry == NULL)
{
bestIFaceEntry = &iface;
continue;
}
//TODO: Why did we have this check? This caused Dictionary to not be able to devirtualize
// calls to TKey GetHashCode when TKey was from a user's project...
/*if (!checkTypeInst->IsTypeMemberAccessible(iface.mDeclaringType, activeTypeDef))
continue;*/
bool isBetter;
bool isWorse;
mModule->CompareDeclTypes(NULL, iface.mDeclaringType, bestIFaceEntry->mDeclaringType, isBetter, isWorse);
if (isBetter == isWorse)
if (iface.mInterfaceType == mBestMethodTypeInstance)
{
// Failed
}
else
{
if (isBetter)
if (bestIFaceEntry == NULL)
{
bestIFaceEntry = &iface;
continue;
}
bool isBetter;
bool isWorse;
mModule->CompareDeclTypes(NULL, iface.mDeclaringType, bestIFaceEntry->mDeclaringType, isBetter, isWorse);
if (isBetter == isWorse)
{
// Failed
}
else
{
if (isBetter)
bestIFaceEntry = &iface;
}
}
}
}

View file

@ -3597,7 +3597,8 @@ void BfModule::AddDependency(BfType* usedType, BfType* userType, BfDependencyMap
if (usedType->IsSpecializedByAutoCompleteMethod())
{
if ((flags & (BfDependencyMap::DependencyFlag_TypeGenericArg | BfDependencyMap::DependencyFlag_OuterType | BfDependencyMap::DependencyFlag_DerivedFrom)) == 0)
if ((flags & (BfDependencyMap::DependencyFlag_TypeGenericArg | BfDependencyMap::DependencyFlag_MethodGenericArg |
BfDependencyMap::DependencyFlag_OuterType | BfDependencyMap::DependencyFlag_DerivedFrom)) == 0)
return;
}