mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Improved protection checks of inner type
This commit is contained in:
parent
7864304d9e
commit
01ba9507c0
2 changed files with 47 additions and 4 deletions
|
@ -5,7 +5,39 @@ using System;
|
|||
namespace Tests
|
||||
{
|
||||
class Protection
|
||||
{
|
||||
{
|
||||
class TypeA
|
||||
{
|
||||
private struct TypeB { }
|
||||
|
||||
public TypeA mValA;
|
||||
public TypeB mValB; //FAIL
|
||||
public TypeC mValC; //FAIL
|
||||
|
||||
private class TypeC
|
||||
{
|
||||
private class TypeD { }
|
||||
|
||||
public class TypeE
|
||||
{
|
||||
private class TypeF { }
|
||||
|
||||
public TypeA mValA;
|
||||
public TypeB mValB;
|
||||
public TypeC mValC;
|
||||
public TypeD mValD; //FAIL
|
||||
public TypeE mValE;
|
||||
public TypeF mValF; //FAIL
|
||||
}
|
||||
|
||||
public TypeA mValA;
|
||||
public TypeB mValB;
|
||||
public TypeC mValC;
|
||||
public TypeD mValD; //FAIL
|
||||
public TypeE mValE;
|
||||
}
|
||||
}
|
||||
|
||||
class ClassA
|
||||
{
|
||||
private int mAPriv;
|
||||
|
|
|
@ -3708,9 +3708,6 @@ bool BfModule::CheckAccessMemberProtection(BfProtection protection, BfTypeInstan
|
|||
|
||||
bool BfModule::CheckDefineMemberProtection(BfProtection protection, BfType* memberType)
|
||||
{
|
||||
// Use 'min' - exporting a 'public' from a 'private' class is really just 'private' still
|
||||
protection = std::min(protection, mCurTypeInstance->mTypeDef->mProtection);
|
||||
|
||||
auto memberTypeInstance = memberType->ToTypeInstance();
|
||||
|
||||
if (memberTypeInstance == NULL)
|
||||
|
@ -3721,6 +3718,20 @@ bool BfModule::CheckDefineMemberProtection(BfProtection protection, BfType* memb
|
|||
return true;
|
||||
}
|
||||
|
||||
if (memberTypeInstance->mTypeDef->mProtection < protection)
|
||||
{
|
||||
// Check for any definition up to the actual declared member type
|
||||
auto commonOuterType = FindCommonOuterType(memberTypeInstance->mTypeDef, mCurTypeInstance->mTypeDef);
|
||||
if (commonOuterType == memberTypeInstance->mTypeDef)
|
||||
commonOuterType = commonOuterType->mOuterType;
|
||||
auto checkTypeDef = mCurTypeInstance->mTypeDef;
|
||||
while ((checkTypeDef != NULL) && (checkTypeDef != commonOuterType))
|
||||
{
|
||||
protection = std::min(protection, checkTypeDef->mProtection);
|
||||
checkTypeDef = checkTypeDef->mOuterType;
|
||||
}
|
||||
}
|
||||
|
||||
if (memberTypeInstance->mTypeDef->mProtection < protection)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue