mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Improvements to auto-impl properties
This commit is contained in:
parent
36e0a3a375
commit
06f4eb9576
8 changed files with 113 additions and 61 deletions
|
@ -20710,6 +20710,9 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
}
|
||||
else if (methodDef->mMethodType == BfMethodType_PropertyGetter)
|
||||
{
|
||||
if ((methodInstance->mReturnType->IsRef()) && (!methodDef->mIsMutating))
|
||||
Fail("Auto-implemented ref property getters must declare 'mut'", methodInstance->mMethodDef->GetRefNode());
|
||||
|
||||
if (methodInstance->mReturnType->IsValuelessType())
|
||||
{
|
||||
mBfIRBuilder->CreateRetVoid();
|
||||
|
@ -20736,8 +20739,14 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
lookupValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(GetThis().mValue, 0, fieldInstance->mDataIdx), fieldInstance->mResolvedType, true);
|
||||
else
|
||||
lookupValue = ExtractValue(GetThis(), fieldInstance, fieldInstance->mDataIdx);
|
||||
if (!methodInstance->mReturnType->IsRef())
|
||||
if (methodInstance->mReturnType->IsRef())
|
||||
{
|
||||
if ((!lookupValue.IsAddr()) && (!lookupValue.mType->IsValuelessType()))
|
||||
lookupValue = MakeAddressable(lookupValue);
|
||||
}
|
||||
else
|
||||
lookupValue = LoadOrAggregateValue(lookupValue);
|
||||
|
||||
CreateReturn(lookupValue.mValue);
|
||||
EmitLifetimeEnds(&mCurMethodState->mHeadScope);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue