mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed generic inner type alias with type extensions
This commit is contained in:
parent
8169587b4c
commit
0154b75923
4 changed files with 62 additions and 8 deletions
|
@ -1704,7 +1704,7 @@ public:
|
|||
BfTypeInstance* GetOuterType(BfType* type);
|
||||
bool IsInnerType(BfType* checkInnerType, BfType* checkOuterType);
|
||||
bool IsInnerType(BfTypeDef* checkInnerType, BfTypeDef* checkOuterType);
|
||||
bool TypeHasParent(BfTypeDef* checkChildTypeDef, BfTypeDef* checkParentTypeDef);
|
||||
bool TypeHasParentOrEquals(BfTypeDef* checkChildTypeDef, BfTypeDef* checkParentTypeDef);
|
||||
BfTypeDef* FindCommonOuterType(BfTypeDef* type, BfTypeDef* type2);
|
||||
bool TypeIsSubTypeOf(BfTypeInstance* srcType, BfTypeInstance* wantType, bool checkAccessibility = true);
|
||||
int GetTypeDistance(BfType* fromType, BfType* toType);
|
||||
|
|
|
@ -215,7 +215,10 @@ bool BfModule::ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstan
|
|||
{
|
||||
auto underlyingType = genericTypeInst->GetUnderlyingType();
|
||||
if ((underlyingType != NULL) && (underlyingType->IsGenericTypeInstance()))
|
||||
{
|
||||
PopulateType(underlyingType, BfPopulateType_Declaration);
|
||||
return ValidateGenericConstraints(typeRef, (BfTypeInstance*)underlyingType, ignoreErrors);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5278,7 +5281,7 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
|||
{
|
||||
bool isFailurePass = pass == 1;
|
||||
bool allowPrivate = (mCurTypeInstance != NULL) &&
|
||||
((mCurTypeInstance == outerTypeInstance) || TypeHasParent(mCurTypeInstance->mTypeDef, outerTypeInstance->mTypeDef));
|
||||
((mCurTypeInstance == outerTypeInstance) || TypeHasParentOrEquals(mCurTypeInstance->mTypeDef, outerTypeInstance->mTypeDef));
|
||||
bool allowProtected = allowPrivate;/*(mCurTypeInstance != NULL) &&
|
||||
(allowPrivate || (mCurTypeInstance->mSkipTypeProtectionChecks) || TypeIsSubTypeOf(mCurTypeInstance, outerTypeInstance));*/
|
||||
|
||||
|
@ -7771,7 +7774,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|||
|
||||
BfTypeDef* outerType = mSystem->GetCombinedPartial(typeDef->mOuterType);
|
||||
BF_ASSERT(!outerType->mIsPartial);
|
||||
if (TypeHasParent(mCurTypeInstance->mTypeDef, outerType))
|
||||
if (TypeHasParentOrEquals(mCurTypeInstance->mTypeDef, outerType))
|
||||
{
|
||||
BfType* checkCurType = mCurTypeInstance;
|
||||
if (checkCurType->IsBoxed())
|
||||
|
@ -10482,15 +10485,28 @@ BfTypedValue BfModule::GetIntCoercible(const BfTypedValue& typedValue)
|
|||
return BfTypedValue(val, intType);
|
||||
}
|
||||
|
||||
bool BfModule::TypeHasParent(BfTypeDef* checkChildTypeDef, BfTypeDef* checkParentTypeDef)
|
||||
bool BfModule::TypeHasParentOrEquals(BfTypeDef* checkChildTypeDef, BfTypeDef* checkParentTypeDef)
|
||||
{
|
||||
BfTypeDef* checkType = checkChildTypeDef;
|
||||
while (checkType != NULL)
|
||||
{
|
||||
|
||||
if (checkType->mNestDepth < checkParentTypeDef->mNestDepth)
|
||||
return false;
|
||||
|
||||
while (checkType->mNestDepth > checkParentTypeDef->mNestDepth)
|
||||
checkType = checkType->mOuterType;
|
||||
|
||||
if (checkType == checkParentTypeDef)
|
||||
return true;
|
||||
checkType = checkType->mOuterType;
|
||||
if (checkType->mNameEx != checkParentTypeDef->mNameEx)
|
||||
return false;
|
||||
|
||||
if (checkType->mIsPartial)
|
||||
{
|
||||
for (auto partial : checkParentTypeDef->mPartials)
|
||||
if (partial == checkType)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace LibA
|
||||
{
|
||||
interface IVal
|
||||
|
@ -26,6 +28,11 @@ namespace LibA
|
|||
let t = new T();
|
||||
delete t;
|
||||
}
|
||||
|
||||
public static bool DictEquals(Dictionary<String, int> lhs, Dictionary<String, int> rhs)
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma warning disable 168
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Collections
|
||||
{
|
||||
|
@ -16,6 +17,26 @@ namespace System.Collections
|
|||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary<K, V>
|
||||
{
|
||||
public static bool operator==(Self lhs, Self rhs) where K : IOpEquals where V : IOpEquals
|
||||
{
|
||||
if (lhs.mCount != rhs.mCount)
|
||||
return false;
|
||||
for (var kv in ref lhs)
|
||||
{
|
||||
if (rhs.TryGetValue(kv.key, var rhsVal))
|
||||
{
|
||||
if (*kv.valueRef != rhsVal)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace System.Collections
|
||||
|
@ -161,6 +182,16 @@ namespace Tests
|
|||
Test.Assert(val == 110);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestDictionary()
|
||||
{
|
||||
Dictionary<String, int> dictLhs = scope .() {("Abc", 123), ("Def", 234) };
|
||||
Dictionary<String, int> dictrhs = scope .() {(scope:: String("Abc"), 123), ("Def", 234) };
|
||||
|
||||
Test.Assert(dictLhs == dictrhs);
|
||||
Test.Assert(!LibA.LibA0.DictEquals(dictLhs, dictrhs));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestSharedData()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue