Permalink
Browse files

Array.cs: Fixed Sort<T> with IComparable (generic or not) bug #77039

svn path=/trunk/mcs/; revision=54696
  • Loading branch information...
1 parent 6a41770 commit 8b9fd26ce2e490415431472e288630e76428df01 Sebastien Pouliot committed Dec 21, 2005
Showing with 12 additions and 6 deletions.
  1. +8 −6 mcs/class/corlib/System/Array.cs
  2. +4 −0 mcs/class/corlib/System/ChangeLog
@@ -1469,13 +1469,15 @@ private static int compare<T> (T value1, T value2, IComparer<T> comparer)
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)
@@ -1,3 +1,7 @@
+2005-12-21 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Array.cs: Fixed Sort<T> with IComparable (generic or not) bug #77039
+
2005-12-20 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* Array.cs: Added the Sort<T> methods (generics).

0 comments on commit 8b9fd26

Please sign in to comment.