mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed error with generic method call on a static field
This commit is contained in:
parent
70c7067bb0
commit
24aaa22f7a
5 changed files with 22 additions and 8 deletions
|
@ -14478,7 +14478,7 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
|
||||||
mModule->Fail("Identifier not found", qualifiedName->mLeft);
|
mModule->Fail("Identifier not found", qualifiedName->mLeft);
|
||||||
mModule->CheckTypeRefFixit(qualifiedName->mLeft);
|
mModule->CheckTypeRefFixit(qualifiedName->mLeft);
|
||||||
mModule->CheckIdentifierFixit(qualifiedName->mLeft);
|
mModule->CheckIdentifierFixit(qualifiedName->mLeft);
|
||||||
thisValue = mModule->GetDefaultTypedValue(mModule->mContext->mBfObjectType);
|
thisValue = mModule->GetDefaultTypedValue(mModule->GetPrimitiveType(BfTypeCode_Var));
|
||||||
}
|
}
|
||||||
if (mResult)
|
if (mResult)
|
||||||
CheckResultForReading(mResult);
|
CheckResultForReading(mResult);
|
||||||
|
|
|
@ -1659,7 +1659,7 @@ public:
|
||||||
void FixIntUnknown(BfTypedValue& typedVal, BfType* matchType = NULL);
|
void FixIntUnknown(BfTypedValue& typedVal, BfType* matchType = NULL);
|
||||||
void FixIntUnknown(BfTypedValue& lhs, BfTypedValue& rhs);
|
void FixIntUnknown(BfTypedValue& lhs, BfTypedValue& rhs);
|
||||||
bool TypeEquals(BfTypedValue& val, BfType* type);
|
bool TypeEquals(BfTypedValue& val, BfType* type);
|
||||||
BfTypeDef* ResolveGenericInstanceDef(BfGenericInstanceTypeRef* genericTypeRef, BfType** outType = NULL);
|
BfTypeDef* ResolveGenericInstanceDef(BfGenericInstanceTypeRef* genericTypeRef, BfType** outType = NULL, BfResolveTypeRefFlags resolveFlags = BfResolveTypeRefFlag_None);
|
||||||
BfType* ResolveType(BfType* lookupType, BfPopulateType populateType = BfPopulateType_Data);
|
BfType* ResolveType(BfType* lookupType, BfPopulateType populateType = BfPopulateType_Data);
|
||||||
void ResolveGenericParamConstraints(BfGenericParamInstance* genericParamInstance, bool isUnspecialized);
|
void ResolveGenericParamConstraints(BfGenericParamInstance* genericParamInstance, bool isUnspecialized);
|
||||||
String GenericParamSourceToString(const BfGenericParamSource& genericParamSource);
|
String GenericParamSourceToString(const BfGenericParamSource& genericParamSource);
|
||||||
|
|
|
@ -5983,7 +5983,7 @@ BfType* BfModule::ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& generic
|
||||||
|
|
||||||
int checkIdx = 0;
|
int checkIdx = 0;
|
||||||
|
|
||||||
BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* genericTypeRef, BfType** outType)
|
BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* genericTypeRef, BfType** outType, BfResolveTypeRefFlags resolveFlags)
|
||||||
{
|
{
|
||||||
if (outType != NULL)
|
if (outType != NULL)
|
||||||
*outType = NULL;
|
*outType = NULL;
|
||||||
|
@ -6061,13 +6061,14 @@ BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* generic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasGenericParam)
|
if ((wasGenericParam) && ((resolveFlags & BfResolveTypeRefFlag_IgnoreLookupError) == 0))
|
||||||
Fail("Cannot use generic param as generic instance type", typeRef);
|
Fail("Cannot use generic param as generic instance type", typeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeDef == NULL)
|
if (typeDef == NULL)
|
||||||
{
|
{
|
||||||
TypeRefNotFound(typeRef);
|
if ((resolveFlags & BfResolveTypeRefFlag_IgnoreLookupError) == 0)
|
||||||
|
TypeRefNotFound(typeRef);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6085,7 +6086,8 @@ BfTypeDef* BfModule::ResolveGenericInstanceDef(BfGenericInstanceTypeRef* generic
|
||||||
return typeInst->mTypeDef;
|
return typeInst->mTypeDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fail("Invalid generic type", typeRef);
|
if ((resolveFlags & BfResolveTypeRefFlag_IgnoreLookupError) == 0)
|
||||||
|
Fail("Invalid generic type", typeRef);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8273,7 +8275,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
}
|
}
|
||||||
|
|
||||||
BfResolvedTypeSet::LookupContext lookupCtx;
|
BfResolvedTypeSet::LookupContext lookupCtx;
|
||||||
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags & BfResolveTypeRefFlag_NoCreate);
|
lookupCtx.mResolveFlags = (BfResolveTypeRefFlags)(resolveFlags & (BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_IgnoreLookupError));
|
||||||
lookupCtx.mRootTypeRef = typeRef;
|
lookupCtx.mRootTypeRef = typeRef;
|
||||||
lookupCtx.mRootTypeDef = typeDef;
|
lookupCtx.mRootTypeDef = typeDef;
|
||||||
lookupCtx.mModule = this;
|
lookupCtx.mModule = this;
|
||||||
|
|
|
@ -2851,7 +2851,7 @@ int BfResolvedTypeSet::Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHash
|
||||||
else if (auto genericInstTypeRef = BfNodeDynCastExact<BfGenericInstanceTypeRef>(typeRef))
|
else if (auto genericInstTypeRef = BfNodeDynCastExact<BfGenericInstanceTypeRef>(typeRef))
|
||||||
{
|
{
|
||||||
//BfType* type = NULL;
|
//BfType* type = NULL;
|
||||||
BfTypeDef* elementTypeDef = ctx->mModule->ResolveGenericInstanceDef(genericInstTypeRef);
|
BfTypeDef* elementTypeDef = ctx->mModule->ResolveGenericInstanceDef(genericInstTypeRef, NULL, ctx->mResolveFlags);
|
||||||
|
|
||||||
if (elementTypeDef == NULL)
|
if (elementTypeDef == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -173,6 +173,16 @@ namespace Tests
|
||||||
delete val;
|
delete val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ClassE
|
||||||
|
{
|
||||||
|
public static Self Instance = new ClassE() ~ delete _;
|
||||||
|
|
||||||
|
public int CreateSystem<T>()
|
||||||
|
{
|
||||||
|
return 999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestBasics()
|
public static void TestBasics()
|
||||||
{
|
{
|
||||||
|
@ -207,6 +217,8 @@ namespace Tests
|
||||||
ClassD cd = scope .();
|
ClassD cd = scope .();
|
||||||
ClassD cd2 = scope .();
|
ClassD cd2 = scope .();
|
||||||
Test.Assert(LibA.LibA2.CheckEq(cd, cd2));
|
Test.Assert(LibA.LibA2.CheckEq(cd, cd2));
|
||||||
|
|
||||||
|
Test.Assert(ClassE.Instance.CreateSystem<int>() == 999);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue