Author: spouliot
Date: 2005-12-21 13:23:17 -0500 (Wed, 21 Dec 2005)
New Revision: 54696

Modified:
   trunk/mcs/class/corlib/System/Array.cs
   trunk/mcs/class/corlib/System/ChangeLog
Log:
Array.cs: Fixed Sort<T> with IComparable (generic or not) bug #77039

Modified: trunk/mcs/class/corlib/System/Array.cs
===================================================================
--- trunk/mcs/class/corlib/System/Array.cs      2005-12-21 18:17:35 UTC (rev 
54695)
+++ trunk/mcs/class/corlib/System/Array.cs      2005-12-21 18:23:17 UTC (rev 
54696)
@@ -1469,13 +1469,15 @@
                                return value2 == null ? 0 : -1;
                        else if (value2 == null)
                                return 1;
-                       else if (comparer == null)
-                               if (value1 is IComparable<T>)
-                                       return ((IComparable<T>) 
value1).CompareTo (value2);
-                               else
-                                       return ((IComparable) value1).CompareTo 
(value2);
-                       else
+                       else if (value1 is IComparable<T>)
+                               return ((IComparable<T>) value1).CompareTo 
(value2);
+                       else if (value1 is IComparable)
+                               return ((IComparable) value1).CompareTo 
(value2);
+                       else if (comparer != null)
                                return comparer.Compare (value1, value2);
+
+                       string msg = Locale.GetText ("No IComparable or 
IComparable<T> interface found for type '{0}'.");
+                       throw new InvalidOperationException (String.Format 
(msg, typeof (T)));
                }
 
                private static void qsort<T> (T [] array, int low0, int high0, 
Comparison<T> comparison)

Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2005-12-21 18:17:35 UTC (rev 
54695)
+++ trunk/mcs/class/corlib/System/ChangeLog     2005-12-21 18:23:17 UTC (rev 
54696)
@@ -1,3 +1,7 @@
+2005-12-21  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+ 
+       * Array.cs: Fixed Sort<T> with IComparable (generic or not) bug #77039
+
 2005-12-20  Carlos Alberto Cortez <[EMAIL PROTECTED]>
 
        * Array.cs: Added the Sort<T> methods (generics). 

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

Reply via email to