1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Fixed some method selection cases with deferred args

This commit is contained in:
Brian Fiete 2025-05-30 07:09:04 +02:00
parent abd547a405
commit c23def10f1
2 changed files with 55 additions and 0 deletions

View file

@ -949,6 +949,10 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
//else if ((!prevWasGenericParam) && (IsType(arg, prevParamType)) && (!IsType(arg, paramType)))
else if ((!wasArgDeferred) && (!prevWasGenericParam) && (IsType(arg, prevParamType)) && ((resolvedArg == NULL) || (paramType != resolvedArg->mBestBoundType)))
isWorse = true;
else if ((wasArgDeferred) && (paramType != prevParamType) && (paramType == arg.mType) && (paramType == resolvedArg->mBestBoundType))
isBetter = true;
else if ((wasArgDeferred) && (paramType != prevParamType) && (prevParamType == arg.mType) && (prevParamType == resolvedArg->mBestBoundType))
isWorse = true;
else
{
bool canCastFromCurToPrev = mModule->CanCast(mModule->GetFakeTypedValue(paramType), prevParamType, implicitCastFlags);

View file

@ -228,6 +228,36 @@ namespace Tests
return fVals[0];
}
static int IntTest(int16 a)
{
return 1;
}
static int IntTest(int32 a)
{
return 2;
}
static int IntTest(int a)
{
return 3;
}
static int IntTest2(int a)
{
return 3;
}
static int IntTest2(int32 a)
{
return 2;
}
static int IntTest2(int16 a)
{
return 1;
}
[Test]
public static void TestBasics()
{
@ -305,6 +335,27 @@ namespace Tests
float4 fVals = .(123, 234, 345, 456);
Test.Assert(GetFirstFloat(*(.)&fVals) == 123);
Test.Assert(GetFirstFloatRef(ref *(.)&fVals) == 123);
const int i = 1;
const int16 i16 = 1;
const int32 i32 = 1;
Test.Assert(IntTest(i16) == 1);
Test.Assert(IntTest(-43) == 1);
Test.Assert(IntTest(i32) == 2);
Test.Assert(IntTest((int32)(-43)) == 2);
Test.Assert(IntTest((int32)-43) == 2);
Test.Assert(IntTest(i) == 3);
Test.Assert(IntTest((int)(-43)) == 3);
Test.Assert(IntTest((int)-43) == 3);
Test.Assert(IntTest2(i16) == 1);
Test.Assert(IntTest2(-43) == 1);
Test.Assert(IntTest2(i32) == 2);
Test.Assert(IntTest2((int32)(-43)) == 2);
Test.Assert(IntTest2((int32)-43) == 2);
Test.Assert(IntTest2(i) == 3);
Test.Assert(IntTest2((int)(-43)) == 3);
Test.Assert(IntTest2((int)-43) == 3);
}
}
}