1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +02:00

Disallowed cast from func constraint to void* or delegate to object

This commit is contained in:
Brian Fiete 2021-12-15 08:42:11 -05:00
parent 7b58863563
commit bb6c59e39e

View file

@ -11513,6 +11513,13 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
{ {
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true); SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, true);
auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance(); auto constraintTypeInst = genericParamInst->mTypeConstraint->ToTypeInstance();
if ((constraintTypeInst != NULL) && (constraintTypeInst->IsDelegateOrFunction()))
{
// Could be a methodref - can't cast to anything else
}
else
{
if ((constraintTypeInst != NULL) && (constraintTypeInst->IsInstanceOf(mCompiler->mEnumTypeDef)) && (explicitCast)) if ((constraintTypeInst != NULL) && (constraintTypeInst->IsInstanceOf(mCompiler->mEnumTypeDef)) && (explicitCast))
{ {
// Enum->int // Enum->int
@ -11538,6 +11545,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
return result; return result;
} }
} }
}
// Generic constrained with class or pointer type -> void* // Generic constrained with class or pointer type -> void*
if (toType->IsVoidPtr()) if (toType->IsVoidPtr())