1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +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) while (checkTypeInst != NULL)
{ {
mModule->PopulateType(checkTypeInst, BfPopulateType_DataAndMethods); 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 for (auto&& iface : checkTypeInst->mInterfaces)
// calls to TKey GetHashCode when TKey was from a user's project...
/*if (!checkTypeInst->IsTypeMemberAccessible(iface.mDeclaringType, activeTypeDef))
continue;*/
if (iface.mInterfaceType == mBestMethodTypeInstance)
{ {
if (bestIFaceEntry == NULL) //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...
bestIFaceEntry = &iface; /*if (!checkTypeInst->IsTypeMemberAccessible(iface.mDeclaringType, activeTypeDef))
continue; continue;*/
}
bool isBetter; if (iface.mInterfaceType == mBestMethodTypeInstance)
bool isWorse;
mModule->CompareDeclTypes(NULL, iface.mDeclaringType, bestIFaceEntry->mDeclaringType, isBetter, isWorse);
if (isBetter == isWorse)
{ {
// Failed if (bestIFaceEntry == NULL)
} {
else
{
if (isBetter)
bestIFaceEntry = &iface; 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 (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; return;
} }