1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Error checking for generic arg count in typeof

This commit is contained in:
Brian Fiete 2021-01-06 05:14:58 -08:00
parent fb2e70c04a
commit 16c4ee40c6

View file

@ -9666,11 +9666,18 @@ BfType* BfModule::ResolveTypeRefAllowUnboundGenerics(BfTypeReference* typeRef, B
auto genericTypeDef = ResolveGenericInstanceDef(genericTypeRef);
if (genericTypeDef == NULL)
return NULL;
BfTypeVector typeVector;
for (int i = 0; i < (int)genericTypeDef->mGenericParamDefs.size(); i++)
typeVector.push_back(GetGenericParamType(BfGenericParamKind_Type, i));
return ResolveTypeDef(genericTypeDef, typeVector, populateType);
auto result = ResolveTypeDef(genericTypeDef, typeVector, populateType);
if ((result != NULL) && (genericTypeRef->mCommas.size() + 1 != genericTypeDef->mGenericParamDefs.size()))
{
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, result->ToTypeInstance());
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
Fail(StrFormat("Type '%s' requires %d generic arguments", TypeToString(result).c_str(), genericTypeDef->mGenericParamDefs.size()), typeRef);
}
return result;
}
}