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

Fixed erroneous autoprop optimization when getter or setter has a body

This commit is contained in:
Brian Fiete 2021-06-29 16:02:42 -07:00
parent 78c39c5f87
commit 91897f8cb3

View file

@ -4871,14 +4871,24 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
{ {
if ((curCheckType->mTypeDef->HasAutoProperty(propertyDeclaration)) && (propertyDeclaration->mVirtualSpecifier == NULL)) if ((curCheckType->mTypeDef->HasAutoProperty(propertyDeclaration)) && (propertyDeclaration->mVirtualSpecifier == NULL))
{ {
bool hasSetter = GetPropertyMethodDef(mPropDef, BfMethodType_PropertySetter, BfCheckedKind_NotSet, mPropTarget) != NULL; BfMethodDef* getter = GetPropertyMethodDef(mPropDef, BfMethodType_PropertySetter, BfCheckedKind_NotSet, mPropTarget);
BfMethodDef* setter = GetPropertyMethodDef(mPropDef, BfMethodType_PropertySetter, BfCheckedKind_NotSet, mPropTarget);
bool optAllowed = true;
if ((getter != NULL) && (getter->mBody != NULL))
optAllowed = false;
if ((setter != NULL) && (setter->mBody != NULL))
optAllowed = false;
if (optAllowed)
{
auto autoFieldName = curCheckType->mTypeDef->GetAutoPropertyName(propertyDeclaration); auto autoFieldName = curCheckType->mTypeDef->GetAutoPropertyName(propertyDeclaration);
auto result = LookupField(targetSrc, target, autoFieldName, (BfLookupFieldFlags)(BfLookupFieldFlag_IgnoreProtection | BfLookupFieldFlag_IsImplicitThis)); auto result = LookupField(targetSrc, target, autoFieldName, (BfLookupFieldFlags)(BfLookupFieldFlag_IgnoreProtection | BfLookupFieldFlag_IsImplicitThis));
if (result) if (result)
{ {
bool needsCopy = true; bool needsCopy = true;
if (!hasSetter) if (setter == NULL)
{ {
if (((mModule->mCurMethodInstance->mMethodDef->mMethodType == BfMethodType_Ctor)) && if (((mModule->mCurMethodInstance->mMethodDef->mMethodType == BfMethodType_Ctor)) &&
(startCheckType == mModule->mCurTypeInstance)) (startCheckType == mModule->mCurTypeInstance))
@ -4903,6 +4913,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
} }
} }
} }
}
SetAndRestoreValue<BfTypedValue> prevResult(mResult, target); SetAndRestoreValue<BfTypedValue> prevResult(mResult, target);
CheckResultForReading(mResult); CheckResultForReading(mResult);