mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed errors during qualified static field reference
This commit is contained in:
parent
c0dd9b0e09
commit
71f677d902
7 changed files with 25 additions and 26 deletions
|
@ -9519,11 +9519,7 @@ void BfExprEvaluator::LookupQualifiedStaticField(BfAstNode* nameNode, BfIdentifi
|
|||
{
|
||||
// Lookup left side as a type
|
||||
{
|
||||
BfType* type = NULL;
|
||||
{
|
||||
SetAndRestoreValue<bool> prevIgnoreErrors(mModule->mIgnoreErrors, true);
|
||||
type = mModule->ResolveTypeRef(nameLeft, NULL, BfPopulateType_Declaration, BfResolveTypeRefFlag_AllowRef);
|
||||
}
|
||||
BfType* type = mModule->ResolveTypeRef(nameLeft, NULL, BfPopulateType_Declaration, BfResolveTypeRefFlag_IgnoreLookupError);
|
||||
if (type != NULL)
|
||||
{
|
||||
BfTypedValue lookupType;
|
||||
|
|
|
@ -1814,7 +1814,7 @@ public:
|
|||
bool ResolveTypeResult_Validate(BfTypeReference* typeRef, BfType* resolvedTypeRef);
|
||||
BfType* ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTypeRef, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags);
|
||||
void ShowAmbiguousTypeError(BfAstNode* refNode, BfTypeDef* typeDef, BfTypeDef* otherTypeDef);
|
||||
void ShowGenericArgCountError(BfTypeReference* typeRef, int wantedGenericParams);
|
||||
void ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericParams);
|
||||
BfTypeDef* GetActiveTypeDef(BfTypeInstance* typeInstanceOverride = NULL, bool useMixinDecl = false); // useMixinDecl is useful for type lookup, but we don't want the decl project to limit what methods the user can call
|
||||
BfTypeDef* FindTypeDefRaw(const BfAtomComposite& findName, int numGenericArgs, BfTypeInstance* typeInstance, BfTypeDef* useTypeDef, BfTypeLookupError* error);
|
||||
BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfTypeInstance* typeInstanceOverride = NULL, BfTypeLookupError* error = NULL);
|
||||
|
@ -1828,11 +1828,9 @@ public:
|
|||
BfType* ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0, int numGenericArgs = 0);
|
||||
BfType* ResolveTypeRefAllowUnboundGenerics(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, bool resolveGenericParam = true);
|
||||
BfType* ResolveTypeRef(BfAstNode* astNode, const BfSizedArray<BfTypeReference*>* genericArgs, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
//BfType* ResolveTypeRef(BfIdentifierNode* identifier, const BfSizedArray<BfTypeReference*>& genericArgs, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
BfType* ResolveTypeDef(BfTypeDef* typeDef, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = BfResolveTypeRefFlag_None);
|
||||
BfType* ResolveTypeDef(BfTypeDef* typeDef, const BfTypeVector& genericArgs, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = BfResolveTypeRefFlag_None);
|
||||
BfType* ResolveInnerType(BfType* outerType, BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, bool ignoreErrors = false, int numGenericArgs = 0);
|
||||
BfType* ResolveInnerType(BfType* outerType, BfIdentifierNode* identifier, BfPopulateType populateType = BfPopulateType_Data, bool ignoreErrors = false);
|
||||
BfType* ResolveInnerType(BfType* outerType, BfAstNode* typeRef, BfPopulateType populateType = BfPopulateType_Data, bool ignoreErrors = false, int numGenericArgs = 0);
|
||||
BfTypeDef* GetCombinedPartialTypeDef(BfTypeDef* type);
|
||||
BfTypeInstance* GetOuterType(BfType* type);
|
||||
bool IsInnerType(BfType* checkInnerType, BfType* checkOuterType);
|
||||
|
|
|
@ -6613,7 +6613,7 @@ void BfModule::HandleMethodGenericParamRef(BfAstNode* refNode, BfTypeDef* typeDe
|
|||
mCompiler->mResolvePassData->HandleMethodGenericParam(refNode, typeDef, methodDef, methodGenericParamIdx);
|
||||
}
|
||||
|
||||
BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef, BfPopulateType populateType, bool ignoreErrors, int numGenericArgs)
|
||||
BfType* BfModule::ResolveInnerType(BfType* outerType, BfAstNode* typeRef, BfPopulateType populateType, bool ignoreErrors, int numGenericArgs)
|
||||
{
|
||||
BfTypeDef* nestedTypeDef = NULL;
|
||||
|
||||
|
@ -6623,6 +6623,7 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
|||
BfNamedTypeReference* namedTypeRef = NULL;
|
||||
BfGenericInstanceTypeRef* genericTypeRef = NULL;
|
||||
BfDirectStrTypeReference* directStrTypeRef = NULL;
|
||||
BfIdentifierNode* identifierNode = NULL;
|
||||
if ((namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef)))
|
||||
{
|
||||
//TYPEDEF nestedTypeDef = namedTypeRef->mTypeDef;
|
||||
|
@ -6632,12 +6633,16 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
|||
namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(genericTypeRef->mElementType);
|
||||
//TYPEDEF nestedTypeDef = namedTypeRef->mTypeDef;
|
||||
}
|
||||
else if ((identifierNode = BfNodeDynCast<BfIdentifierNode>(typeRef)))
|
||||
{
|
||||
//TYPEDEF nestedTypeDef = namedTypeRef->mTypeDef;
|
||||
}
|
||||
else if ((directStrTypeRef = BfNodeDynCast<BfDirectStrTypeReference>(typeRef)))
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
BF_ASSERT((namedTypeRef != NULL) || (directStrTypeRef != NULL));
|
||||
BF_ASSERT((identifierNode != NULL) || (namedTypeRef != NULL) || (directStrTypeRef != NULL));
|
||||
|
||||
auto usedOuterType = outerType;
|
||||
if (nestedTypeDef == NULL)
|
||||
|
@ -6645,6 +6650,8 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
|||
StringView findName;
|
||||
if (namedTypeRef != NULL)
|
||||
findName = namedTypeRef->mNameNode->ToStringView();
|
||||
else if (identifierNode != NULL)
|
||||
findName = identifierNode->ToStringView();
|
||||
else
|
||||
findName = directStrTypeRef->mTypeName;
|
||||
|
||||
|
@ -6744,7 +6751,7 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
|||
genericArgs.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
ShowGenericArgCountError(typeRef, (int)nestedTypeDef->mGenericParamDefs.size() - (int)nestedTypeDef->mOuterType->mGenericParamDefs.size());
|
||||
return NULL;
|
||||
}
|
||||
|
@ -8083,7 +8090,7 @@ void BfModule::ShowAmbiguousTypeError(BfAstNode* refNode, BfTypeDef* typeDef, Bf
|
|||
}
|
||||
}
|
||||
|
||||
void BfModule::ShowGenericArgCountError(BfTypeReference* typeRef, int wantedGenericParams)
|
||||
void BfModule::ShowGenericArgCountError(BfAstNode* typeRef, int wantedGenericParams)
|
||||
{
|
||||
BfGenericInstanceTypeRef* genericTypeInstRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef);
|
||||
|
||||
|
@ -10363,15 +10370,6 @@ BfTypeInstance* BfModule::GetUnspecializedTypeInstance(BfTypeInstance* typeInst)
|
|||
return result->ToTypeInstance();
|
||||
}
|
||||
|
||||
BfType* BfModule::ResolveInnerType(BfType* outerType, BfIdentifierNode* identifier, BfPopulateType populateType, bool ignoreErrors)
|
||||
{
|
||||
BfDirectStrTypeReference typeRef;
|
||||
typeRef.Init(identifier->ToString());
|
||||
// There is no ref node so we ignore errors
|
||||
auto type = ResolveInnerType(outerType, &typeRef, populateType, /*ignoreErrors*/true);
|
||||
return type;
|
||||
}
|
||||
|
||||
BfType* BfModule::ResolveTypeRef(BfAstNode* astNode, const BfSizedArray<BfTypeReference*>* genericArgs, BfPopulateType populateType, BfResolveTypeRefFlags resolveFlags)
|
||||
{
|
||||
if ((genericArgs == NULL) || (genericArgs->size() == 0))
|
||||
|
|
|
@ -4548,8 +4548,15 @@ void BfTypeUtils::PopulateType(BfModule* module, BfType* type)
|
|||
module->PopulateType(type);
|
||||
}
|
||||
|
||||
String BfTypeUtils::TypeToString(BfTypeReference* typeRef)
|
||||
String BfTypeUtils::TypeToString(BfAstNode* typeRefNode)
|
||||
{
|
||||
if (auto identifierNode = BfNodeDynCast<BfIdentifierNode>(typeRefNode))
|
||||
return identifierNode->ToString();
|
||||
|
||||
auto typeRef = BfNodeDynCast<BfTypeReference>(typeRefNode);
|
||||
if (typeRef == NULL)
|
||||
return "";
|
||||
|
||||
if (auto typeDefTypeRef = BfNodeDynCast<BfDirectTypeDefReference>(typeRef))
|
||||
{
|
||||
if (!typeDefTypeRef->mTypeDef->mNamespace.IsEmpty())
|
||||
|
|
|
@ -2553,7 +2553,7 @@ class BfTypeUtils
|
|||
{
|
||||
public:
|
||||
static String HashEncode64(uint64 val); // Note: this only encodes 60 bits
|
||||
static String TypeToString(BfTypeReference* typeRef);
|
||||
static String TypeToString(BfAstNode* typeRef);
|
||||
static String TypeToString(BfTypeDef* typeDef, BfTypeNameFlags typeNameFlags = BfTypeNameFlags_None);
|
||||
static bool TypeToString(StringImpl& str, BfTypeDef* typeDef, BfTypeNameFlags typeNameFlags = BfTypeNameFlags_None);
|
||||
static bool TypeEquals(BfType* typeA, BfType* typeB, BfType* selfType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue