diff options
author | Martin Baulig <martin@novell.com> | 2004-11-10 02:13:17 +0300 |
---|---|---|
committer | Martin Baulig <martin@novell.com> | 2004-11-10 02:13:17 +0300 |
commit | 2ce246b7a6ce1690c9c866a59b098c82442c0841 (patch) | |
tree | 7b62eb37a20ed7f11518a76ba65aef466b9eb6dd /mcs | |
parent | a17130c3e1ffa22365fe81cda6e2ce6f1b2cf0c2 (diff) |
2004-11-10 Martin Baulig <martin@localhost>
* typemanager.cs
(TypeManager.IsPrivateAccessible): New public method.
(Closure.Filter): Use IsPrivateAccessible() instead of IsEqual().
svn path=/trunk/mcs/; revision=35926
Diffstat (limited to 'mcs')
-rwxr-xr-x | mcs/gmcs/ChangeLog | 6 | ||||
-rwxr-xr-x | mcs/gmcs/typemanager.cs | 48 |
2 files changed, 51 insertions, 3 deletions
diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog index 64a1c20af6a..33e07f32624 100755 --- a/mcs/gmcs/ChangeLog +++ b/mcs/gmcs/ChangeLog @@ -1,3 +1,9 @@ +2004-11-10 Martin Baulig <martin@localhost> + + * typemanager.cs + (TypeManager.IsPrivateAccessible): New public method. + (Closure.Filter): Use IsPrivateAccessible() instead of IsEqual(). + 2004-11-10 Martin Baulig <martin@ximian.com> * class.cs (TypeContainer.DefineType): Call diff --git a/mcs/gmcs/typemanager.cs b/mcs/gmcs/typemanager.cs index 3048d8dd4eb..7e08cc98e86 100755 --- a/mcs/gmcs/typemanager.cs +++ b/mcs/gmcs/typemanager.cs @@ -1946,6 +1946,48 @@ public class TypeManager { return false; } + public static bool IsPrivateAccessible (Type type, Type parent) + { + if (type.Equals (parent)) + return true; + + if ((type is TypeBuilder) && type.IsGenericTypeDefinition && parent.IsGenericInstance) { + // + // `a' is a generic type definition's TypeBuilder and `b' is a + // generic instance of the same type. + // + // Example: + // + // class Stack<T> + // { + // void Test (Stack<T> stack) { } + // } + // + // The first argument of `Test' will be the generic instance + // "Stack<!0>" - which is the same type than the "Stack" TypeBuilder. + // + // + // We hit this via Closure.Filter() for gen-82.cs. + // + if (type != parent.GetGenericTypeDefinition ()) + return false; + + return true; + } + + if (type.IsGenericInstance && parent.IsGenericInstance) { + Type tdef = type.GetGenericTypeDefinition (); + Type pdef = parent.GetGenericTypeDefinition (); + + if (type.GetGenericTypeDefinition () != parent.GetGenericTypeDefinition ()) + return false; + + return true; + } + + return false; + } + public static bool IsFamilyAccessible (Type type, Type parent) { TypeParameter tparam = LookupTypeParameter (type); @@ -2834,7 +2876,7 @@ public class TypeManager { if (ma == MethodAttributes.Private) return private_ok || - IsEqual (invocation_type, mb.DeclaringType) || + IsPrivateAccessible (invocation_type, mb.DeclaringType) || IsNestedChildOf (invocation_type, mb.DeclaringType); // @@ -2885,7 +2927,7 @@ public class TypeManager { if (fa == FieldAttributes.Private) return private_ok || - IsEqual (invocation_type, fi.DeclaringType) || + IsPrivateAccessible (invocation_type, fi.DeclaringType) || IsNestedChildOf (invocation_type, fi.DeclaringType); // @@ -2946,7 +2988,7 @@ public class TypeManager { if (((qualifier_type == null) || (qualifier_type == invocation_type)) && (invocation_type != null) && - IsEqual (m.DeclaringType, invocation_type)) + IsPrivateAccessible (m.DeclaringType, invocation_type)) return true; // |