mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Improved generic constraint const conversion handling
This commit is contained in:
parent
c750ed076c
commit
e5c4321440
4 changed files with 35 additions and 3 deletions
|
@ -13510,7 +13510,15 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
|||
// .. and we can convert the constraint's toType to OUR toType then we're good
|
||||
auto opToVal = genericParam->mExternType;
|
||||
if (CanCast(BfTypedValue(BfIRValue::sValueless, opToVal), toType, BfCastFlags_NoConversionOperator))
|
||||
return mBfIRBuilder->GetFakeVal();
|
||||
{
|
||||
if (mBfIRBuilder->IsConstValue(typedVal.mValue))
|
||||
{
|
||||
// Retain constness
|
||||
return mBfIRBuilder->GetUndefConstValue(mBfIRBuilder->MapType(toType));
|
||||
}
|
||||
else
|
||||
return mBfIRBuilder->GetFakeVal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13535,7 +13543,15 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
|||
// .. and we can convert the constraint's toType to OUR toType then we're good
|
||||
auto opToVal = genericParam->mExternType;
|
||||
if (CanCast(BfTypedValue(BfIRValue::sValueless, opToVal), toType, BfCastFlags_NoConversionOperator))
|
||||
return mBfIRBuilder->GetFakeVal();
|
||||
{
|
||||
if (mBfIRBuilder->IsConstValue(typedVal.mValue))
|
||||
{
|
||||
// Retain constness
|
||||
return mBfIRBuilder->GetUndefConstValue(mBfIRBuilder->MapType(toType));
|
||||
}
|
||||
else
|
||||
return mBfIRBuilder->GetFakeVal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue