mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
undef instead of fakeVal in const variation, fix typeAlias generic
This commit is contained in:
parent
bc39fe6204
commit
f4aa6c26ff
2 changed files with 21 additions and 13 deletions
|
@ -9389,11 +9389,11 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod
|
||||||
if (contextTypeInstance->IsBoxed())
|
if (contextTypeInstance->IsBoxed())
|
||||||
genericCheckTypeInstance = contextTypeInstance->GetUnderlyingType()->ToTypeInstance();
|
genericCheckTypeInstance = contextTypeInstance->GetUnderlyingType()->ToTypeInstance();
|
||||||
|
|
||||||
bool doFakeVal = false;
|
bool doUndefVal = false;
|
||||||
if (genericCheckTypeInstance->IsUnspecializedTypeVariation())
|
if (genericCheckTypeInstance->IsUnspecializedTypeVariation())
|
||||||
{
|
{
|
||||||
genericCheckTypeInstance = GetUnspecializedTypeInstance(genericCheckTypeInstance);
|
genericCheckTypeInstance = GetUnspecializedTypeInstance(genericCheckTypeInstance);
|
||||||
doFakeVal = true;
|
doUndefVal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfGenericParamDef* genericParamDef = NULL;
|
BfGenericParamDef* genericParamDef = NULL;
|
||||||
|
@ -9497,9 +9497,9 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod
|
||||||
}
|
}
|
||||||
else if (genericParamResult->IsGenericParam())
|
else if (genericParamResult->IsGenericParam())
|
||||||
{
|
{
|
||||||
if ((doFakeVal) && (genericTypeConstraint != NULL))
|
if ((doUndefVal) && (genericTypeConstraint != NULL))
|
||||||
{
|
{
|
||||||
return BfTypedValue(mBfIRBuilder->GetFakeVal(), genericTypeConstraint);
|
return GetDefaultTypedValue(genericTypeConstraint, false, BfDefaultValueKind_Undef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((genericParamDef->mGenericParamFlags | origGenericParamDef->mGenericParamFlags) & BfGenericParamFlag_Const) != 0)
|
if (((genericParamDef->mGenericParamFlags | origGenericParamDef->mGenericParamFlags) & BfGenericParamFlag_Const) != 0)
|
||||||
|
@ -10649,21 +10649,20 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
genericTypeInst->mTypeDef = typeDef;
|
genericTypeInst->mTypeDef = typeDef;
|
||||||
|
|
||||||
if ((commonOuterType != NULL) && (outerTypeInstance->IsGenericTypeInstance()))
|
auto parentTypeInstance = outerTypeInstance;
|
||||||
{
|
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsTypeAlias()))
|
||||||
auto parentTypeInstance = outerTypeInstance;
|
parentTypeInstance = (BfTypeInstance*)GetOuterType(parentTypeInstance)->ToTypeInstance();
|
||||||
if (parentTypeInstance->IsTypeAlias())
|
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsGenericTypeInstance()))
|
||||||
parentTypeInstance = (BfTypeInstance*)GetOuterType(parentTypeInstance)->ToTypeInstance();
|
{
|
||||||
genericTypeInst->mGenericTypeInfo->mMaxGenericDepth = BF_MAX(genericTypeInst->mGenericTypeInfo->mMaxGenericDepth, parentTypeInstance->mGenericTypeInfo->mMaxGenericDepth);
|
genericTypeInst->mGenericTypeInfo->mMaxGenericDepth = BF_MAX(genericTypeInst->mGenericTypeInfo->mMaxGenericDepth, parentTypeInstance->mGenericTypeInfo->mMaxGenericDepth);
|
||||||
for (int i = 0; i < startDefGenericParamIdx; i++)
|
for (int i = 0; i < startDefGenericParamIdx; i++)
|
||||||
{
|
{
|
||||||
genericTypeInst->mGenericTypeInfo->mGenericParams.push_back(parentTypeInstance->mGenericTypeInfo->mGenericParams[i]->AddRef());
|
genericTypeInst->mGenericTypeInfo->mGenericParams.push_back(parentTypeInstance->mGenericTypeInfo->mGenericParams[i]->AddRef());
|
||||||
genericTypeInst->mGenericTypeInfo->mTypeGenericArguments.push_back(parentTypeInstance->mGenericTypeInfo->mTypeGenericArguments[i]);
|
genericTypeInst->mGenericTypeInfo->mTypeGenericArguments.push_back(parentTypeInstance->mGenericTypeInfo->mTypeGenericArguments[i]);
|
||||||
auto typeGenericArg = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[i];
|
auto typeGenericArg = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[i];
|
||||||
genericTypeInst->mGenericTypeInfo->mIsUnspecialized |= typeGenericArg->IsGenericParam() || typeGenericArg->IsUnspecializedType();
|
genericTypeInst->mGenericTypeInfo->mIsUnspecialized |= typeGenericArg->IsGenericParam() || typeGenericArg->IsUnspecializedType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int wantedGenericParams = genericParamCount - startDefGenericParamIdx;
|
int wantedGenericParams = genericParamCount - startDefGenericParamIdx;
|
||||||
int genericArgDiffCount = (int)genericArguments.size() - wantedGenericParams;
|
int genericArgDiffCount = (int)genericArguments.size() - wantedGenericParams;
|
||||||
|
|
|
@ -105,6 +105,13 @@ namespace Tests
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typealias BigNum<N> = BigNum<N,const 0>;
|
||||||
|
public struct BigNum<ArgN, ExponentCells> where ArgN : const int where ExponentCells : const int64
|
||||||
|
{
|
||||||
|
static int CalculateN() => Math.Max(1,(int)ArgN);
|
||||||
|
public const int N = CalculateN();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestBasics()
|
public static void TestBasics()
|
||||||
{
|
{
|
||||||
|
@ -117,6 +124,8 @@ namespace Tests
|
||||||
Test.Assert(iList.SequenceEquals(iSpan));
|
Test.Assert(iList.SequenceEquals(iSpan));
|
||||||
iList.Add(4);
|
iList.Add(4);
|
||||||
Test.Assert(!iList.SequenceEquals(iSpan));
|
Test.Assert(!iList.SequenceEquals(iSpan));
|
||||||
|
|
||||||
|
Test.Assert(BigNum<const 3>.N == 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue