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

Prefer 'out' to 'ref' for method selection

This commit is contained in:
Brian Fiete 2024-06-26 08:44:26 +02:00
parent 7767df89dc
commit ded495a07b

View file

@ -971,6 +971,17 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
}
}
if ((!isBetter) && (!isWorse) && (paramType->IsRef()) && (prevParamType->IsRef()))
{
auto refType = (BfRefType*)paramType;
auto prevRefType = (BfRefType*)prevParamType;
// Prefer 'out' to 'ref'
SET_BETTER_OR_WORSE(
(refType->mRefKind == BfRefType::RefKind_Out) && (prevRefType->mRefKind == BfRefType::RefKind_Ref),
(refType->mRefKind == BfRefType::RefKind_Ref) && (prevRefType->mRefKind == BfRefType::RefKind_Out));
}
if ((newArgIdx >= 0) && (newMethodInstance->GetParamKind(newArgIdx) == BfParamKind_Params))
usedExtendedForm = true;
if ((prevArgIdx >= 0) && (prevMethodInstance->GetParamKind(prevArgIdx) == BfParamKind_Params))