Author: martin
Date: 2006-07-21 09:04:43 -0400 (Fri, 21 Jul 2006)
New Revision: 62857

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/convert.cs
   trunk/mcs/gmcs/generic.cs
Log:
2006-07-21  Martin Baulig  <[EMAIL PROTECTED]>

        * generic.cs (TypeManager.IsIEnumerable): Renamed into IsIList()
        and allow IList`1 and all its base interfaces.

        * convert.cs (Convert.ImplicitReferenceConversion): Allow
        converting from an array-type of T to IList<T>.



Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2006-07-21 13:03:05 UTC (rev 62856)
+++ trunk/mcs/gmcs/ChangeLog    2006-07-21 13:04:43 UTC (rev 62857)
@@ -1,5 +1,13 @@
 2006-07-21  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * generic.cs (TypeManager.IsIEnumerable): Renamed into IsIList()
+       and allow IList`1 and all its base interfaces.
+
+       * convert.cs (Convert.ImplicitReferenceConversion): Allow
+       converting from an array-type of T to IList<T>.
+
+2006-07-21  Martin Baulig  <[EMAIL PROTECTED]>
+
        * ecore.cs (SimpleName.DoSimpleNameResolve): Added CS0307 check.
 
 2006-07-20  Miguel de Icaza  <[EMAIL PROTECTED]>

Modified: trunk/mcs/gmcs/convert.cs
===================================================================
--- trunk/mcs/gmcs/convert.cs   2006-07-21 13:03:05 UTC (rev 62856)
+++ trunk/mcs/gmcs/convert.cs   2006-07-21 13:04:43 UTC (rev 62857)
@@ -280,8 +280,8 @@
                        if (expr_type.IsArray && target_type == 
TypeManager.array_type)
                                return new EmptyCast (expr, target_type);
 
-                       // from an array-type of type T to IEnumerable<T>
-                       if (expr_type.IsArray && TypeManager.IsIEnumerable 
(expr_type, target_type))
+                       // from an array-type of type T to IList<T>
+                       if (expr_type.IsArray && TypeManager.IsIList 
(expr_type, target_type))
                                return new EmptyCast (expr, target_type);
 
                        // from any delegate type to System.Delegate
@@ -376,8 +376,8 @@
                        if (expr_type.IsArray && (target_type == 
TypeManager.array_type))
                                return true;
 
-                       // from an array-type of type T to IEnumerable<T>
-                       if (expr_type.IsArray && TypeManager.IsIEnumerable 
(expr_type, target_type))
+                       // from an array-type of type T to IList<T>
+                       if (expr_type.IsArray && TypeManager.IsIList 
(expr_type, target_type))
                                return true;
 
                        // from any delegate type to System.Delegate

Modified: trunk/mcs/gmcs/generic.cs
===================================================================
--- trunk/mcs/gmcs/generic.cs   2006-07-21 13:03:05 UTC (rev 62856)
+++ trunk/mcs/gmcs/generic.cs   2006-07-21 13:04:43 UTC (rev 62857)
@@ -1942,6 +1942,8 @@
                // A list of core types that the compiler requires or uses
                //
                static public Type activator_type;
+               static public Type generic_ilist_type;
+               static public Type generic_icollection_type;
                static public Type generic_ienumerator_type;
                static public Type generic_ienumerable_type;
                static public Type generic_nullable_type;
@@ -1970,6 +1972,10 @@
                {
                        activator_type = CoreLookupType ("System", "Activator");
 
+                       generic_ilist_type = CoreLookupType (
+                               "System.Collections.Generic", "IList", 1);
+                       generic_icollection_type = CoreLookupType (
+                               "System.Collections.Generic", "ICollection", 1);
                        generic_ienumerator_type = CoreLookupType (
                                "System.Collections.Generic", "IEnumerator", 1);
                        generic_ienumerable_type = CoreLookupType (
@@ -2110,18 +2116,20 @@
                }
 
                //
-               // Whether `array' is an array of T and `enumerator' is 
`IEnumerable<T>'.
-               // For instance "string[]" -> "IEnumerable<string>".
+               // Whether `array' is an array of T and `list' is `IList<T>'.
+               // For instance "string[]" -> "IList<string>".
                //
-               public static bool IsIEnumerable (Type array, Type enumerator)
+               public static bool IsIList (Type array, Type list)
                {
-                       if (!array.IsArray || !enumerator.IsGenericType)
+                       if (!array.IsArray || !list.IsGenericType)
                                return false;
 
-                       if (enumerator.GetGenericTypeDefinition () != 
generic_ienumerable_type)
+                       Type gt = list.GetGenericTypeDefinition ();
+                       if ((gt != generic_ilist_type) && (gt != 
generic_icollection_type) &&
+                           (gt != generic_ienumerable_type))
                                return false;
 
-                       Type[] args = GetTypeArguments (enumerator);
+                       Type[] args = GetTypeArguments (list);
                        return args [0] == GetElementType (array);
                }
 

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

Reply via email to