Author: marek
Date: 2008-02-14 06:22:59 -0500 (Thu, 14 Feb 2008)
New Revision: 95613

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/decl.cs
Log:
2008-02-14  Marek Safar  <[EMAIL PROTECTED]>

        A fix for bug #361686
        * decl.cs: A protected types used inside a private class which parents 
        derives from the protected class are accessible.
        


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2008-02-14 09:53:58 UTC (rev 95612)
+++ trunk/mcs/mcs/ChangeLog     2008-02-14 11:22:59 UTC (rev 95613)
@@ -1,3 +1,9 @@
+2008-02-14  Marek Safar  <[EMAIL PROTECTED]>
+
+       A fix for bug #361686
+       * decl.cs: A protected types used inside a private class which parents 
+       derives from the protected class are accessible.
+
 2008-02-13  Marek Safar  <[EMAIL PROTECTED]>
 
        * generic.cs (ConstraintChecker): Use cached member lookup when looking 
for

Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs       2008-02-14 09:53:58 UTC (rev 95612)
+++ trunk/mcs/mcs/decl.cs       2008-02-14 11:22:59 UTC (rev 95613)
@@ -565,7 +565,7 @@
                                        continue;
 
                                bool same_access_restrictions = false;
-                               for (MemberCore mc = this; 
!same_access_restrictions && mc.Parent != null; mc = mc.Parent) {
+                               for (MemberCore mc = this; 
!same_access_restrictions && mc != null && mc.Parent != null; mc = mc.Parent) {
                                        AccessLevel al = 
GetAccessLevelFromModifiers (mc.ModFlags);
                                        switch (pAccess) {
                                                case AccessLevel.Internal:
@@ -575,18 +575,31 @@
                                                        break;
 
                                                case AccessLevel.Protected:
-                                                       if (al == 
AccessLevel.Protected)
+                                                       if (al == 
AccessLevel.Protected) {
                                                                
same_access_restrictions = mc.Parent.IsBaseType (p_parent);
+                                                               break;
+                                                       }
+
+                                                       if (al == 
AccessLevel.Private) {
+                                                               //
+                                                               // When type is 
private and any of its parents derives from
+                                                               // protected 
type then the type is accessible
+                                                               //
+                                                               while 
(mc.Parent != null) {
+                                                                       if 
(mc.Parent.IsBaseType (p_parent))
+                                                                               
same_access_restrictions = true;
+                                                                       mc = 
mc.Parent; 
+                                                               }
+                                                       }
+
                                                        break;
 
                                                case 
AccessLevel.ProtectedOrInternal:
                                                        if (al == 
AccessLevel.Protected)
                                                                
same_access_restrictions = mc.Parent.IsBaseType (p_parent);
-
-                                                       if (al == 
AccessLevel.Internal)
+                                                       else if (al == 
AccessLevel.Internal)
                                                                
same_access_restrictions = CodeGen.Assembly.Builder == p.Assembly || 
TypeManager.IsFriendAssembly (p.Assembly);
-
-                                                       if (al == 
AccessLevel.ProtectedOrInternal)
+                                                       else if (al == 
AccessLevel.ProtectedOrInternal)
                                                                
same_access_restrictions = mc.Parent.IsBaseType (p_parent) &&
                                                                        
(CodeGen.Assembly.Builder == p.Assembly || TypeManager.IsFriendAssembly 
(p.Assembly));
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to