Author: martin
Date: 2006-03-06 19:39:56 -0500 (Mon, 06 Mar 2006)
New Revision: 57639
Added:
trunk/mcs/tests/gtest-251.cs
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/generic.cs
Log:
2006-03-07 Martin Baulig <[EMAIL PROTECTED]>
* generic.cs (TypeManager.InferType): Allow infering
`IEnumerable<T>' with an array of T; see gtest-251.cs.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2006-03-06 21:19:33 UTC (rev 57638)
+++ trunk/mcs/gmcs/ChangeLog 2006-03-07 00:39:56 UTC (rev 57639)
@@ -1,3 +1,8 @@
+2006-03-07 Martin Baulig <[EMAIL PROTECTED]>
+
+ * generic.cs (TypeManager.InferType): Allow infering
+ `IEnumerable<T>' with an array of T; see gtest-251.cs.
+
2006-03-06 Martin Baulig <[EMAIL PROTECTED]>
* generic.cs
Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs 2006-03-06 21:19:33 UTC (rev 57638)
+++ trunk/mcs/gmcs/generic.cs 2006-03-07 00:39:56 UTC (rev 57639)
@@ -2369,11 +2369,19 @@
}
if (at.IsArray) {
- if (!pt.IsArray ||
- (at.GetArrayRank () != pt.GetArrayRank ()))
- return false;
+ if (pt.IsArray) {
+ if (at.GetArrayRank () !=
pt.GetArrayRank ())
+ return false;
- return InferType (pt.GetElementType (),
at.GetElementType (), infered);
+ return InferType (pt.GetElementType (),
at.GetElementType (), infered);
+ }
+
+ if (!pt.IsGenericType ||
+ (pt.GetGenericTypeDefinition () !=
generic_ienumerable_type))
+ return false;
+
+ Type[] args = GetTypeArguments (pt);
+ return InferType (args [0], at.GetElementType
(), infered);
}
if (pt.IsArray) {
Added: trunk/mcs/tests/gtest-251.cs
===================================================================
--- trunk/mcs/tests/gtest-251.cs 2006-03-06 21:19:33 UTC (rev 57638)
+++ trunk/mcs/tests/gtest-251.cs 2006-03-07 00:39:56 UTC (rev 57639)
@@ -0,0 +1,22 @@
+using System;
+using SCG = System.Collections.Generic;
+
+public interface ISorted<S>
+{
+ void AddSorted<T> (SCG.IEnumerable<T> items)
+ where T : S;
+}
+
+public class SortedIndexedTester<T>
+{
+ public void Test (ISorted<int> sorted)
+ {
+ sorted.AddSorted (new int[] { 31, 62, 63, 93 });
+ }
+}
+
+class X
+{
+ static void Main ()
+ { }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches