Fix part of #79451
authorRaja R Harinath <harinath@hurrynot.org>
Fri, 22 Sep 2006 13:54:51 +0000 (13:54 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Fri, 22 Sep 2006 13:54:51 +0000 (13:54 -0000)
* typemanager.cs (Closure.Filter): Consider PrivateScope attributes.
* decl.cs (DeclSpace.FindMemberToOverride): Likewise.  Reorganize
code slightly.

svn path=/trunk/mcs/; revision=65815

mcs/mcs/ChangeLog
mcs/mcs/decl.cs
mcs/mcs/typemanager.cs

index 7eacaf537fa7e0ff08d6f1c9cfbda62cb003adc3..563c44629d0883ac71823045b7cfc8404c0b2590 100644 (file)
@@ -1,3 +1,10 @@
+2006-09-22  Raja R Harinath  <rharinath@novell.com>
+
+       Fix part of #79451
+       * typemanager.cs (Closure.Filter): Consider PrivateScope attributes.
+       * decl.cs (DeclSpace.FindMemberToOverride): Likewise.  Reorganize
+       code slightly.
+
 2006-09-22  Martin Baulig  <martin@ximian.com>
 
        * ecore.cs: Merged with the gmcs version.
index 4468288f0e034863f57e27b0e9d852bbc97d7c37..0be96f1ca5721b503f303f8f32f8d4332acae062 100644 (file)
@@ -2116,24 +2116,25 @@ namespace Mono.CSharp {
                                        // TODO: Almost duplicate !
                                        // Check visibility
                                        switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
-                                               case FieldAttributes.Private:
-                                                       //
-                                                       // A private method is Ok if we are a nested subtype.
-                                                       // The spec actually is not very clear about this, see bug 52458.
-                                                       //
-                                                       if (invocationType != entry.Container.Type &
-                                                               TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
-                                                               continue;
-
-                                                       break;
-                                               case FieldAttributes.FamANDAssem:
-                                               case FieldAttributes.Assembly:
-                                                       //
-                                                       // Check for assembly methods
-                                                       //
-                                                       if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
-                                                               continue;
-                                                       break;
+                                       case FieldAttributes.PrivateScope:
+                                               continue;
+                                       case FieldAttributes.Private:
+                                               //
+                                               // A private method is Ok if we are a nested subtype.
+                                               // The spec actually is not very clear about this, see bug 52458.
+                                               //
+                                               if (!invocationType.Equals (entry.Container.Type) &&
+                                                   !TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
+                                                       continue;
+                                               break;
+                                       case FieldAttributes.FamANDAssem:
+                                       case FieldAttributes.Assembly:
+                                               //
+                                               // Check for assembly methods
+                                               //
+                                               if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
+                                                       continue;
+                                               break;
                                        }
                                        return entry.Member;
                                }
@@ -2144,23 +2145,24 @@ namespace Mono.CSharp {
                                if (cmpAttrs.Length != paramTypes.Length)
                                        continue;
        
-                               for (int j = cmpAttrs.Length - 1; j >= 0; j --) {
+                               int j;
+                               for (j = 0; j < cmpAttrs.Length; ++j)
                                        if (!TypeManager.IsEqual (paramTypes [j], cmpAttrs [j]))
-                                               goto next;
-                               }
+                                               break;
+                               if (j < cmpAttrs.Length)
+                                       continue;
 
                                //
                                // check generic arguments for methods
                                //
                                if (mi != null) {
                                        Type [] cmpGenArgs = TypeManager.GetGenericArguments (mi);
-                                       if ((genericMethod != null) && (cmpGenArgs.Length > 0)) {
-                                               if (genericMethod.TypeParameters.Length != cmpGenArgs.Length)
-                                               goto next;
-                                       } else if (!((genericMethod == null) && (cmpGenArgs.Length == 0)))
-                                               goto next;
+                                       if (genericMethod == null && cmpGenArgs.Length != 0)
+                                               continue;
+                                       if (genericMethod != null && cmpGenArgs.Length != genericMethod.TypeParameters.Length)
+                                               continue;
                                }
-                               
+
                                //
                                // get one of the methods because this has the visibility info.
                                //
@@ -2174,34 +2176,27 @@ namespace Mono.CSharp {
                                // Check visibility
                                //
                                switch (mi.Attributes & MethodAttributes.MemberAccessMask) {
+                               case MethodAttributes.PrivateScope:
+                                       continue;
                                case MethodAttributes.Private:
                                        //
                                        // A private method is Ok if we are a nested subtype.
                                        // The spec actually is not very clear about this, see bug 52458.
                                        //
-                                       if (invocationType.Equals (entry.Container.Type) ||
-                                           TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
-                                               return entry.Member;
-                                       
+                                       if (!invocationType.Equals (entry.Container.Type) &&
+                                           !TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
+                                               continue;
                                        break;
                                case MethodAttributes.FamANDAssem:
                                case MethodAttributes.Assembly:
                                        //
                                        // Check for assembly methods
                                        //
-                                       if (mi.DeclaringType.Assembly == CodeGen.Assembly.Builder)
-                                               return entry.Member;
-                                       
+                                       if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
+                                               continue;
                                        break;
-                               default:
-                                       //
-                                       // A protected method is ok, because we are overriding.
-                                       // public is always ok.
-                                       //
-                                       return entry.Member;
                                }
-                       next:
-                               ;
+                               return entry.Member;
                        }
                        
                        return null;
index 7f559b47671c7f601e174fe93af5fc7ea5e225b9..34d45c0d11bfe03c08bf1875e43f1cd4a8e3e819 100644 (file)
@@ -2992,7 +2992,10 @@ public partial class TypeManager {
 
                                if (ma == MethodAttributes.Public)
                                        return true;
-                               
+
+                               if (ma == MethodAttributes.PrivateScope)
+                                       return false;
+
                                if (ma == MethodAttributes.Private)
                                        return private_ok ||
                                                IsPrivateAccessible (invocation_type, m.DeclaringType) ||
@@ -3017,7 +3020,10 @@ public partial class TypeManager {
                                
                                if (fa == FieldAttributes.Public)
                                        return true;
-                               
+
+                               if (fa == FieldAttributes.PrivateScope)
+                                       return false;
+
                                if (fa == FieldAttributes.Private)
                                        return private_ok ||
                                                IsPrivateAccessible (invocation_type, m.DeclaringType) ||