mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed issue with local methods in generic types
This commit is contained in:
parent
5403cdb748
commit
ee4ae8f9ed
3 changed files with 35 additions and 9 deletions
|
@ -19315,7 +19315,10 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valueless types always compare as 'equal'
|
// Valueless types always compare as 'equal'
|
||||||
if ((leftValue.mType == rightValue.mType) && (leftValue.mType->IsValuelessType()))
|
if (leftValue.mType == rightValue.mType)
|
||||||
|
{
|
||||||
|
mModule->PopulateType(leftValue.mType);
|
||||||
|
if (leftValue.mType->IsValuelessType())
|
||||||
{
|
{
|
||||||
auto boolType = mModule->GetPrimitiveType(BfTypeCode_Boolean);
|
auto boolType = mModule->GetPrimitiveType(BfTypeCode_Boolean);
|
||||||
bool isEqual = (binaryOp == BfBinaryOp_Equality) || (binaryOp == BfBinaryOp_StrictEquality);
|
bool isEqual = (binaryOp == BfBinaryOp_Equality) || (binaryOp == BfBinaryOp_StrictEquality);
|
||||||
|
@ -19323,6 +19326,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((leftValue.mType->IsTypeInstance()) || (leftValue.mType->IsGenericParam()) ||
|
if ((leftValue.mType->IsTypeInstance()) || (leftValue.mType->IsGenericParam()) ||
|
||||||
(rightValue.mType->IsTypeInstance()) || (rightValue.mType->IsGenericParam()))
|
(rightValue.mType->IsTypeInstance()) || (rightValue.mType->IsGenericParam()))
|
||||||
|
|
|
@ -9481,7 +9481,7 @@ BfMethodInstance* BfModule::GetUnspecializedMethodInstance(BfMethodInstance* met
|
||||||
auto owner = methodInstance->mMethodInstanceGroup->mOwner;
|
auto owner = methodInstance->mMethodInstanceGroup->mOwner;
|
||||||
|
|
||||||
if (!useUnspecializedType)
|
if (!useUnspecializedType)
|
||||||
return GetRawMethodInstanceAtIdx(owner, methodInstance->mMethodDef->mIdx);
|
return methodInstance;
|
||||||
|
|
||||||
if (!owner->IsGenericTypeInstance())
|
if (!owner->IsGenericTypeInstance())
|
||||||
return methodInstance;
|
return methodInstance;
|
||||||
|
@ -17320,9 +17320,9 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
methodState.mGenericTypeBindings = &methodInstance->GetMethodInfoEx()->mGenericTypeBindings;
|
methodState.mGenericTypeBindings = &methodInstance->GetMethodInfoEx()->mGenericTypeBindings;
|
||||||
}
|
}
|
||||||
else if ((((methodInstance->mMethodInfoEx != NULL) && ((int)methodInstance->mMethodInfoEx->mMethodGenericArguments.size() > dependentGenericStartIdx)) ||
|
else if ((((methodInstance->mMethodInfoEx != NULL) && ((int)methodInstance->mMethodInfoEx->mMethodGenericArguments.size() > dependentGenericStartIdx)) ||
|
||||||
((mCurTypeInstance->IsGenericTypeInstance()) && (!isGenericVariation))))
|
((mCurTypeInstance->IsGenericTypeInstance()) && (!isGenericVariation) && (!methodInstance->mMethodDef->mIsLocalMethod))))
|
||||||
{
|
{
|
||||||
unspecializedMethodInstance = GetUnspecializedMethodInstance(methodInstance);
|
unspecializedMethodInstance = GetUnspecializedMethodInstance(methodInstance, !methodInstance->mMethodDef->mIsLocalMethod);
|
||||||
|
|
||||||
BF_ASSERT(unspecializedMethodInstance != methodInstance);
|
BF_ASSERT(unspecializedMethodInstance != methodInstance);
|
||||||
if (!unspecializedMethodInstance->mHasBeenProcessed)
|
if (!unspecializedMethodInstance->mHasBeenProcessed)
|
||||||
|
|
|
@ -6,6 +6,25 @@ namespace Tests
|
||||||
{
|
{
|
||||||
class LocalFunctions
|
class LocalFunctions
|
||||||
{
|
{
|
||||||
|
class ClassA<T>
|
||||||
|
{
|
||||||
|
public int Get<T2>()
|
||||||
|
{
|
||||||
|
int LocalA()
|
||||||
|
{
|
||||||
|
return 123;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LocalB<T3>(T3 val) where T3 : IHashable
|
||||||
|
{
|
||||||
|
val.GetHashCode();
|
||||||
|
return 234;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LocalA() + LocalB(1.2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
static void TestA()
|
static void TestA()
|
||||||
{
|
{
|
||||||
|
@ -23,6 +42,9 @@ namespace Tests
|
||||||
|
|
||||||
FuncA();
|
FuncA();
|
||||||
Test.Assert(a == 101);
|
Test.Assert(a == 101);
|
||||||
|
|
||||||
|
ClassA<int> ca = scope .();
|
||||||
|
Test.Assert(ca.Get<int16>() == 357);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue