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

Change in comparison operator selection priority

This commit is contained in:
Brian Fiete 2021-11-01 11:08:10 -07:00
parent 17d2db4cc4
commit 918a28bfb7

View file

@ -1071,6 +1071,17 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
RETURN_RESULTS;
}
// For operators, prefer explicit comparison over '<=>' comparison operator
if ((!isBetter) && (!isWorse))
{
if ((prevMethodDef->mIsOperator) && (newMethodDef->mIsOperator))
{
bool newIsComparison = ((BfOperatorDeclaration*)newMethodDef->mMethodDeclaration)->mBinOp == BfBinaryOp_Compare;
bool prevIsComparison = ((BfOperatorDeclaration*)prevMethodDef->mMethodDeclaration)->mBinOp == BfBinaryOp_Compare;
RETURN_BETTER_OR_WORSE(!newIsComparison, !prevIsComparison);
}
}
if ((newMethodInstance->mMethodDef->mExternalConstraints.size() != 0) || (prevMethodInstance->mMethodDef->mExternalConstraints.size() != 0))
{
struct GenericParamPair
@ -1119,18 +1130,7 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
// If both are empty partials then just bind to either
isWorse = true;
RETURN_RESULTS;
}
// For operators, prefer explicit comparison over '<=>' comparison operator
if ((!isBetter) && (!isWorse))
{
if ((prevMethodDef->mIsOperator) && (newMethodDef->mIsOperator))
{
bool newIsComparison = ((BfOperatorDeclaration*)newMethodDef->mMethodDeclaration)->mBinOp == BfBinaryOp_Compare;
bool prevIsComparison = ((BfOperatorDeclaration*)prevMethodDef->mMethodDeclaration)->mBinOp == BfBinaryOp_Compare;
RETURN_BETTER_OR_WORSE(!newIsComparison, !prevIsComparison);
}
}
}
// For extensions, select the version in the most-specific project (only applicable for ctors)
if ((!isBetter) && (!isWorse))