2004-10-14 Umadevi S <sumadevi@novell.com>
[mono.git] / mcs / gmcs / typemanager.cs
index 0052768acbb04c76cd0f2dac8f28efb11f180a2e..b23fb8a15bbe84874f4b0fb659a804ce82e3106e 100755 (executable)
@@ -1725,43 +1725,7 @@ public class TypeManager {
                return tc.Kind == Kind.Interface;
        }
 
-       public static bool IsEqualGenericType (Type a, Type b)
-       {
-               if ((a is TypeBuilder) && a.IsGenericTypeDefinition && b.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.
-                       //
-                       if (a != b.GetGenericTypeDefinition ())
-                               return false;
-
-                       Type[] aparams = a.GetGenericArguments ();
-                       Type[] bparams = b.GetGenericArguments ();
-
-                       if (aparams.Length != bparams.Length)
-                               return false;
-
-                       for (int i = 0; i < aparams.Length; i++)
-                               if (!aparams [i].Equals (bparams [i]))
-                                       return false;
-
-                       return true;
-               }
-
-               return false;
-       }
-
-       public static bool Real_IsEqual (Type a, Type b)
+       public static bool IsEqual (Type a, Type b)
        {
                if (a.Equals (b))
                        return true;
@@ -1781,6 +1745,9 @@ public class TypeManager {
                        // 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 (a != b.GetGenericTypeDefinition ())
                                return false;
 
@@ -1791,18 +1758,24 @@ public class TypeManager {
                                return false;
 
                        for (int i = 0; i < aparams.Length; i++)
-                               if (!aparams [i].Equals (bparams [i]))
+                               if (!IsEqual (aparams [i], bparams [i]))
                                        return false;
 
                        return true;
                }
 
                if (a.IsGenericParameter && b.IsGenericParameter) {
-                       if ((a.DeclaringMethod != null) != (b.DeclaringMethod != null))
+                       if ((a.DeclaringMethod == null) || (b.DeclaringMethod == null))
                                return false;
                        return a.GenericParameterPosition == b.GenericParameterPosition;
                }
 
+               if (a.IsArray && b.IsArray) {
+                       if (a.GetArrayRank () != b.GetArrayRank ())
+                               return false;
+                       return IsEqual (a.GetElementType (), b.GetElementType ());
+               }
+
                if (a.IsGenericInstance && b.IsGenericInstance) {
                        Type at = a.GetGenericTypeDefinition ();
                        Type bt = b.GetGenericTypeDefinition ();
@@ -1817,7 +1790,7 @@ public class TypeManager {
                                return false;
 
                        for (int i = 0; i < aargs.Length; i++) {
-                               if (Real_IsEqual (aargs [i], bargs [i]))
+                               if (!IsEqual (aargs [i], bargs [i]))
                                        return false;
                        }
 
@@ -1827,14 +1800,6 @@ public class TypeManager {
                return false;
        }
 
-       public static bool IsEqual (Type a, Type b)
-       {
-               if (a.Equals (b))
-                       return true;
-               else
-                       return IsEqualGenericType (a, b);
-       }
-
        public static bool MayBecomeEqualGenericTypes (Type a, Type b)
        {
                if (a.IsGenericParameter) {