mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Added 'concrete' constraint
This commit is contained in:
parent
51ed3df320
commit
e3f51e39ed
12 changed files with 90 additions and 72 deletions
|
@ -1350,6 +1350,8 @@ void BfModule::StartExtension()
|
|||
mStaticFieldRefs.Clear();
|
||||
for (auto& kv : mInterfaceSlotRefs)
|
||||
kv.mValue = BfIRValue();
|
||||
for (auto& pairVal : mDeferredMethodCallData)
|
||||
delete pairVal.mValue;
|
||||
mDeferredMethodCallData.Clear();
|
||||
mDeferredMethodIds.Clear();
|
||||
|
||||
|
@ -5142,11 +5144,6 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
BfMangler::Mangle(typeDataName, mCompiler->GetMangleKind(), type, mContext->mScratchModule);
|
||||
}
|
||||
|
||||
if (typeDataName == "?sBfTypeData@@bf@@2HA")
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
int typeCode = BfTypeCode_None;
|
||||
|
||||
if (typeInstance != NULL)
|
||||
|
@ -7482,6 +7479,15 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS
|
|||
}
|
||||
}
|
||||
|
||||
if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Concrete) &&
|
||||
((checkGenericParamFlags & (BfGenericParamFlag_Interface | BfGenericParamFlag_Var)) == 0) && (checkArgType->IsInterface()))
|
||||
{
|
||||
if (!ignoreErrors)
|
||||
*errorOut = Fail(StrFormat("The type '%s' must be an concrete type in order to use it as parameter '%s' for '%s'",
|
||||
TypeToString(origCheckArgType).c_str(), genericParamInst->GetName().c_str(), GenericParamSourceToString(genericParamSource).c_str()), checkArgTypeRef);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_Interface) &&
|
||||
((checkGenericParamFlags & (BfGenericParamFlag_Interface | BfGenericParamFlag_Var)) == 0) && (!checkArgType->IsInterface()))
|
||||
{
|
||||
|
@ -7711,19 +7717,6 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS
|
|||
}
|
||||
}
|
||||
|
||||
if ((genericParamInst->mInterfaceConstraints.size() > 0) && (origCheckArgType->IsInterface()))
|
||||
{
|
||||
PopulateType(origCheckArgType);
|
||||
auto checkTypeInst = origCheckArgType->ToTypeInstance();
|
||||
if (checkTypeInst->mTypeDef->mIsConcrete)
|
||||
{
|
||||
if (!ignoreErrors)
|
||||
*errorOut = Fail(StrFormat("Generic argument '%s', declared to be concrete interface '%s' for '%s', must be a concrete type", genericParamInst->GetName().c_str(),
|
||||
TypeToString(origCheckArgType).c_str()), checkArgTypeRef);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto checkConstraint : genericParamInst->mInterfaceConstraints)
|
||||
{
|
||||
BfType* convCheckConstraint = checkConstraint;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue