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

Fixed generic extension methods with primitive 'this'

This commit is contained in:
Brian Fiete 2020-12-01 11:35:10 -08:00
parent d976ea77e9
commit 222d030aa4
3 changed files with 42 additions and 2 deletions

View file

@ -1574,7 +1574,12 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
{
BfTypedValue argTypedValue;
if (argIdx == -1)
argTypedValue = mTarget;
{
if (mOrigTarget)
argTypedValue = mOrigTarget;
else
argTypedValue = mTarget;
}
else
argTypedValue = ResolveArgTypedValue(mArguments[argIdx], checkType, genericArgumentsSubstitute, origCheckType);
if (!argTypedValue.IsUntypedValue())
@ -7292,6 +7297,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
BfTypeInstance* curTypeInst = targetTypeInst;
BfMethodMatcher methodMatcher(targetSrc, mModule, methodName, argValues.mResolvedArgs, methodGenericArguments);
methodMatcher.mOrigTarget = origTarget;
methodMatcher.mTarget = target;
methodMatcher.mCheckedKind = checkedKind;
methodMatcher.mAllowImplicitThis = allowImplicitThis;
@ -19674,6 +19680,8 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
bool isComparison = (binaryOp >= BfBinaryOp_Equality) && (binaryOp <= BfBinaryOp_LessThanOrEqual);
BfBinaryOp oppositeBinaryOp = BfGetOppositeBinaryOp(findBinaryOp);
BfBinaryOp flippedBinaryOp = BfGetFlippedBinaryOp(findBinaryOp);
BfBinaryOp flippedOppositeBinaryOp = BfGetFlippedBinaryOp(oppositeBinaryOp);
for (int pass = 0; pass < 2; pass++)
{
@ -19898,7 +19906,15 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
if ((mModule->CanCast(args[0].mTypedValue, opConstraint.mLeftType)) &&
(mModule->CanCast(args[1].mTypedValue, opConstraint.mRightType)))
{
works = true;
works = true;
}
}
if ((flippedBinaryOp != BfBinaryOp_None) && (opConstraint.mBinaryOp == flippedBinaryOp))
{
if ((mModule->CanCast(args[1].mTypedValue, opConstraint.mLeftType)) &&
(mModule->CanCast(args[0].mTypedValue, opConstraint.mRightType)))
{
works = true;
}
}
@ -19911,6 +19927,14 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
works = true;
}
}
if ((flippedOppositeBinaryOp != BfBinaryOp_None) && (opConstraint.mBinaryOp == flippedOppositeBinaryOp))
{
if ((mModule->CanCast(args[1].mTypedValue, opConstraint.mRightType)) &&
(mModule->CanCast(args[0].mTypedValue, opConstraint.mLeftType)))
{
works = true;
}
}
if ((isComparison) && (opConstraint.mBinaryOp == BfBinaryOp_Compare))
{