1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Fixed Friend check for properties

This commit is contained in:
Brian Fiete 2020-03-09 06:51:41 -07:00
parent 14ac27c977
commit d1c373420b
2 changed files with 8 additions and 8 deletions

View file

@ -13985,11 +13985,12 @@ BfModuleMethodInstance BfExprEvaluator::GetPropertyMethodInstance(BfMethodDef* m
return mModule->GetMethodInstance(propTypeInst, methodDef, BfTypeVector(), mPropGetMethodFlags);
}
void BfExprEvaluator::CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance)
void BfExprEvaluator::CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance, bool checkProt)
{
auto propTypeInst = mPropTarget.mType->ToTypeInstance();
// If mExplicitInterface is null then we are implicitly calling through an interface
if ((propTypeInst != NULL) && (methodInstance->GetExplicitInterface() == NULL) && (!mModule->CheckAccessMemberProtection(propMethodDef->mProtection, propTypeInst)))
if ((checkProt) && (propTypeInst != NULL) && (methodInstance->GetExplicitInterface() == NULL) &&
(!mModule->CheckAccessMemberProtection(propMethodDef->mProtection, propTypeInst)))
mModule->Fail(StrFormat("'%s' is inaccessible due to its protection level", mModule->MethodToString(methodInstance).c_str()), mPropSrc);
else if (mPropCheckedKind != methodInstance->mMethodDef->mCheckedKind)
{
@ -14069,9 +14070,8 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
if (mPropSrc != NULL)
mModule->UpdateExprSrcPos(mPropSrc);
if ((mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0)
CheckPropFail(matchedMethod, methodInstance.mMethodInstance);
CheckPropFail(matchedMethod, methodInstance.mMethodInstance, (mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0);
PerformCallChecks(methodInstance.mMethodInstance, mPropSrc);
if (methodInstance.mMethodInstance->IsSkipCall())
@ -14910,8 +14910,8 @@ void BfExprEvaluator::PerformAssignment(BfAssignmentExpression* assignExpr, bool
if (methodInstance.mMethodInstance == NULL)
return;
BF_ASSERT(methodInstance.mMethodInstance->mMethodDef == setMethod);
CheckPropFail(setMethod, methodInstance.mMethodInstance);
CheckPropFail(setMethod, methodInstance.mMethodInstance, (mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0);
BfTypedValue convVal;
if (binaryOp != BfBinaryOp_None)
{

View file

@ -329,7 +329,7 @@ public:
BfTypedValue ResolveArgValue(BfResolvedArg& resolvedArg, BfType* wantType, BfTypedValue* receivingValue = NULL, BfParamKind paramKind = BfParamKind_Normal);
BfMethodDef* GetPropertyMethodDef(BfPropertyDef* propDef, BfMethodType methodType, BfCheckedKind checkedKind);
BfModuleMethodInstance GetPropertyMethodInstance(BfMethodDef* methodDef);
void CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance);
void CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance, bool checkProt);
bool HasResult();
BfTypedValue GetResult(bool clearResult = false, bool resolveGenericType = false);
void CheckResultForReading(BfTypedValue& typedValue);