2002-11-21 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Thu, 21 Nov 2002 19:31:38 +0000 (19:31 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Thu, 21 Nov 2002 19:31:38 +0000 (19:31 -0000)
* typemanager.cs (FilterWithClosure): Commented out the test for
1540 in typemanager.cs, as it has problems when accessing
protected methods from a parent class (see test-174.cs).

Notice that 1540 is still caught elsewhere.

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

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs
mcs/mcs/typemanager.cs

index 2e970a6d57dd5f64734469991cdeac918175de69..29c0c4837b27daecb3cd48bf8e97e338a7ee7447 100755 (executable)
@@ -1,5 +1,11 @@
 2002-11-21  Miguel de Icaza  <miguel@ximian.com>
 
+       * typemanager.cs (FilterWithClosure): Commented out the test for
+       1540 in typemanager.cs, as it has problems when accessing
+       protected methods from a parent class (see test-174.cs). 
+
+       Notice that 1540 is still caught elsewhere.
+
        * attribute.cs (Attribute.ValidateGuid): new method.
        (Attribute.Resolve): Use above.
 
index e4d3a448bc56f18af35fc62f38adb313bfa0fe6b..e44a5bda568f53c9f5aa5005cdbe478dbe1201ef 100755 (executable)
@@ -4186,7 +4186,7 @@ namespace Mono.CSharp {
                        MemberInfo[] group;
 
                        group = TypeManager.MemberLookup (
-                               PropertyInfo.DeclaringType, PropertyInfo.DeclaringType,
+                               invocation_type, PropertyInfo.DeclaringType,
                                MemberTypes.Method, flags, accessor_name + "_" + PropertyInfo.Name);
 
                        //
@@ -4198,14 +4198,20 @@ namespace Mono.CSharp {
                        foreach (MethodInfo mi in group) {
                                MethodAttributes ma = mi.Attributes & MethodAttributes.MemberAccessMask;
 
-                               // If only accessible to the current class.
+                               //
+                               // If only accessible to the current class or children
+                               //
                                if (ma == MethodAttributes.Private) {
-                                       if (mi.DeclaringType != invocation_type)
-                                               continue;
-                                       else
+                                       Type declaring_type = mi.DeclaringType;
+                                       
+                                       if (invocation_type != declaring_type){
+                                               if (TypeManager.IsSubclassOrNestedChildOf (invocation_type, mi.DeclaringType))
+                                                       return mi;
+                                               else
+                                                       continue;
+                                       } else
                                                return mi;
                                }
-
                                //
                                // FamAndAssem requires that we not only derivate, but we are on the
                                // same assembly.  
index fbeb9c608c606bda9ca59794db7e805b4964af80..7ecd974d915ae9c6b2a789af6d01de20f509e08b 100755 (executable)
@@ -1996,12 +1996,20 @@ public class TypeManager {
                                if (!IsSubclassOrNestedChildOf (closure_invocation_type, mb.DeclaringType))
                                        return false;
 
+#if false
+                               //
+                               // See test 174 for a sample.  Essentially, it is ok in a derived
+                               // class to invoke a base class protected method.  1540 is still caught
+                               // elsewhere
+                               //
+                               
                                // Although a derived class can access protected members of its base class
                                // it cannot do so through an instance of the base class (CS1540).
                                if (!mb.IsStatic && (closure_invocation_type != closure_start_type) &&
-                                   closure_invocation_type.IsSubclassOf (closure_start_type))
+                                   closure_start_type != mb.DeclaringType)
                                        return false;
-
+#endif
+                               
                                return true;
                        }
 
@@ -2043,12 +2051,18 @@ public class TypeManager {
                                if (!IsSubclassOrNestedChildOf (closure_invocation_type, fi.DeclaringType))
                                        return false;
 
+#if false
+                               //
+                               // See test-174 for a sample.
+                               //
+                               
                                // Although a derived class can access protected members of its base class
                                // it cannot do so through an instance of the base class (CS1540).
                                if (!fi.IsStatic && (closure_invocation_type != closure_start_type) &&
-                                   closure_invocation_type.IsSubclassOf (closure_start_type))
+                                   closure_start_type != fi.DeclaringType)
                                        return false;
-
+#endif
+                               
                                return true;
                        }
 
@@ -2108,20 +2122,8 @@ public class TypeManager {
                // If we are a nested class, we always have access to our container
                // type names
                //
-               if (invocation_type != null){
-                       string invocation_name = invocation_type.FullName;
-                       if (invocation_name.IndexOf ('+') != -1){
-                               string container = queried_type.FullName + "+";
-                               int container_length = container.Length;
-                               
-                               if (invocation_name.Length > container_length){
-                                       string shared = invocation_name.Substring (0, container_length);
-                               
-                                       if (shared == container)
-                                               always_ok_flag = true;
-                               }
-                       }
-               }
+               if (invocation_type != null)
+                       always_ok_flag = IsSubclassOrNestedChildOf (invocation_type, queried_type);
                
                do {
                        MemberList list;