Author: marek
Date: 2006-11-02 17:49:51 -0500 (Thu, 02 Nov 2006)
New Revision: 67301

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/statement.cs
Log:
2006-11-02  Marek Safar  <[EMAIL PROTECTED]>

        * statement.cs.cs (CollectionForeach.TryType): Issue a error when
        IEnumerable<T> is ambiguous.

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2006-11-02 22:27:03 UTC (rev 67300)
+++ trunk/mcs/mcs/ChangeLog     2006-11-02 22:49:51 UTC (rev 67301)
@@ -1,7 +1,12 @@
+2006-11-02  Marek Safar  <[EMAIL PROTECTED]>
+
+       * statement.cs.cs (CollectionForeach.TryType): Issue a error when
+       IEnumerable<T> is ambiguous.
+
 2006-10-31  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #67689
-       statement.cs.cs (CollectionForeach.TryType): Issue a warning when
+       * statement.cs.cs (CollectionForeach.TryType): Issue a warning when
        GetEnumerator is ambiguous.
 
        * report.cs: Add new warning.

Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs  2006-11-02 22:27:03 UTC (rev 67300)
+++ trunk/mcs/mcs/statement.cs  2006-11-02 22:49:51 UTC (rev 67301)
@@ -4900,7 +4900,7 @@
                                if (mg == null)
                                        return false;
 
-                               MethodBase result = null;
+                               MethodInfo result = null;
                                MethodInfo tmp_move_next = null;
                                PropertyExpr tmp_get_cur = null;
                                Type tmp_enumerator_type = enumerator_type;
@@ -4921,6 +4921,16 @@
                                                continue;
 
                                        if (result != null) {
+                                               if (TypeManager.IsGenericType 
(result.ReturnType)) {
+                                                       if 
(!TypeManager.IsGenericType (mi.ReturnType))
+                                                               continue;
+
+                                                       
Report.SymbolRelatedToPreviousError(t);
+                                                       Report.Error(1640, loc, 
"foreach statement cannot operate on variables of type `{0}' " +
+                                                               "because it 
contains multiple implementation of `{1}'. Try casting to a specific 
implementation",
+                                                               
TypeManager.CSharpName (t), TypeManager.CSharpSignature (mi));
+                                                       return false;
+                                               }
                                                
Report.SymbolRelatedToPreviousError (result);
                                                
Report.SymbolRelatedToPreviousError (mi);
                                                Report.Warning (278, 2, loc, 
"`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is 
ambiguous with method `{3}'",
@@ -4959,12 +4969,16 @@
 
                        bool ProbeCollectionType (EmitContext ec, Type t)
                        {
+                               int errors = Report.Errors;
                                for (Type tt = t; tt != null && tt != 
TypeManager.object_type;){
                                        if (TryType (ec, tt))
                                                return true;
                                        tt = tt.BaseType;
                                }
 
+                               if (Report.Errors > errors)
+                                       return false;
+
                                //
                                // Now try to find the method in the interfaces
                                //

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

Reply via email to