mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
More extern constraints work
This commit is contained in:
parent
d35ef0e1e8
commit
35505d905a
7 changed files with 34 additions and 10 deletions
|
@ -443,7 +443,7 @@ namespace System
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static int Sign<T>(T value) where int : operator T <=> T, ICanBeNaN
|
public static int Sign<T>(T value) where int : operator T <=> T where T : ICanBeNaN
|
||||||
{
|
{
|
||||||
if (value < default)
|
if (value < default)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -453,7 +453,7 @@ namespace System
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Runtime.FatalError("Cannot be used on NaN");
|
Runtime.FatalError("Cannot be used on NaN");
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public static int32 DivRem(int32 a, int32 b, out int32 result)
|
public static int32 DivRem(int32 a, int32 b, out int32 result)
|
||||||
{
|
{
|
||||||
|
|
|
@ -209,15 +209,15 @@ void BfMethodMatcher::Init(/*SizedArrayImpl<BfResolvedArg>& arguments, */BfSized
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfMethodMatcher::IsMemberAccessible(BfTypeInstance* typeInst, BfTypeDef* declaringType)
|
bool BfMethodMatcher::IsMemberAccessible(BfTypeInstance* typeInst, BfTypeDef* declaringType)
|
||||||
{
|
{
|
||||||
if (mActiveTypeDef == NULL)
|
if (mActiveTypeDef == NULL)
|
||||||
mActiveTypeDef = mModule->GetActiveTypeDef();
|
mActiveTypeDef = mModule->GetActiveTypeDef();
|
||||||
if (!typeInst->IsTypeMemberIncluded(declaringType, mActiveTypeDef, mModule))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// This may not be completely correct - BUT if we don't have this then even Dictionary TKey's operator == won't be considered accessible
|
// This may not be completely correct - BUT if we don't have this then even Dictionary TKey's operator == won't be considered accessible
|
||||||
if ((!mModule->IsInSpecializedSection()) && (mActiveTypeDef->mTypeDeclaration != NULL))
|
if ((!mModule->IsInSpecializedSection()) && (mActiveTypeDef->mTypeDeclaration != NULL))
|
||||||
{
|
{
|
||||||
|
if (!typeInst->IsTypeMemberIncluded(declaringType, mActiveTypeDef, mModule))
|
||||||
|
return false;
|
||||||
if (!typeInst->IsTypeMemberAccessible(declaringType, mActiveTypeDef))
|
if (!typeInst->IsTypeMemberAccessible(declaringType, mActiveTypeDef))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -931,8 +931,13 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
|
||||||
auto prevMethodGenericParam = prevMethodInstance->mMethodInfoEx->mGenericParams[genericParamIdx];
|
auto prevMethodGenericParam = prevMethodInstance->mMethodInfoEx->mGenericParams[genericParamIdx];
|
||||||
SET_BETTER_OR_WORSE(mModule->AreConstraintsSubset(prevMethodGenericParam, newMethodGenericParam), mModule->AreConstraintsSubset(newMethodGenericParam, prevMethodGenericParam));
|
SET_BETTER_OR_WORSE(mModule->AreConstraintsSubset(prevMethodGenericParam, newMethodGenericParam), mModule->AreConstraintsSubset(newMethodGenericParam, prevMethodGenericParam));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if ((!isBetter) && (!isWorse))
|
||||||
|
{
|
||||||
|
SET_BETTER_OR_WORSE(newMethodInstance->HasExternConstraints(), prevMethodInstance->HasExternConstraints());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((isBetter) || (isWorse))
|
if ((isBetter) || (isWorse))
|
||||||
{
|
{
|
||||||
RETURN_RESULTS;
|
RETURN_RESULTS;
|
||||||
|
|
|
@ -12788,9 +12788,11 @@ bool BfModule::InDefinitionSection()
|
||||||
|
|
||||||
bool BfModule::IsInSpecializedGeneric()
|
bool BfModule::IsInSpecializedGeneric()
|
||||||
{
|
{
|
||||||
|
if (mCurTypeInstance->IsSpecializedType())
|
||||||
|
return true;
|
||||||
if ((mCurMethodInstance == NULL) || (mCurMethodInstance->mIsUnspecialized))
|
if ((mCurMethodInstance == NULL) || (mCurMethodInstance->mIsUnspecialized))
|
||||||
return false;
|
return false;
|
||||||
return (mCurMethodInstance->GetNumGenericArguments() != 0) || (mCurTypeInstance->IsGenericTypeInstance());
|
return (mCurMethodInstance->GetNumGenericArguments() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfModule::IsInSpecializedSection()
|
bool BfModule::IsInSpecializedSection()
|
||||||
|
|
|
@ -645,6 +645,11 @@ bool BfMethodInstance::IsSpecializedByAutoCompleteMethod()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BfMethodInstance::HasExternConstraints()
|
||||||
|
{
|
||||||
|
return (mMethodInfoEx != NULL) && (mMethodInfoEx->mGenericParams.size() > mMethodInfoEx->mMethodGenericArguments.size());
|
||||||
|
}
|
||||||
|
|
||||||
bool BfMethodInstance::HasParamsArray()
|
bool BfMethodInstance::HasParamsArray()
|
||||||
{
|
{
|
||||||
if (mParams.size() == 0)
|
if (mParams.size() == 0)
|
||||||
|
|
|
@ -865,6 +865,7 @@ public:
|
||||||
bool IsSpecializedGenericMethod();
|
bool IsSpecializedGenericMethod();
|
||||||
bool IsSpecializedGenericMethodOrType();
|
bool IsSpecializedGenericMethodOrType();
|
||||||
bool IsSpecializedByAutoCompleteMethod();
|
bool IsSpecializedByAutoCompleteMethod();
|
||||||
|
bool HasExternConstraints();
|
||||||
bool HasThis();
|
bool HasThis();
|
||||||
bool HasExplicitThis();
|
bool HasExplicitThis();
|
||||||
bool HasParamsArray();
|
bool HasParamsArray();
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Tests
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
public static T Total<T>(this List<T> list) where T : IOpAddable
|
public static T Total<T>(this List<T> list) where T : operator T + T
|
||||||
{
|
{
|
||||||
T total = default;
|
T total = default;
|
||||||
for (let val in list)
|
for (let val in list)
|
||||||
|
|
|
@ -116,9 +116,20 @@ namespace Tests
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct Entry
|
||||||
|
{
|
||||||
|
public static int operator<=>(Entry lhs, Entry rhs)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestBasics()
|
public static void TestBasics()
|
||||||
{
|
{
|
||||||
|
List<Entry> list = scope .();
|
||||||
|
list.Sort();
|
||||||
|
|
||||||
ClassA ca = scope .();
|
ClassA ca = scope .();
|
||||||
ClassB cb = scope .();
|
ClassB cb = scope .();
|
||||||
Test.Assert(LibA.LibA0.GetVal(ca) == 123);
|
Test.Assert(LibA.LibA0.GetVal(ca) == 123);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue