Author: raja
Date: 2007-01-11 06:52:18 -0500 (Thu, 11 Jan 2007)
New Revision: 70850

Added:
   trunk/mcs/tests/gtest-302.cs
Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/statement.cs
   trunk/mcs/tests/ChangeLog
Log:
Fix #80249
* mcs/statement.cs (CollectionForeach.TryType): Prefer generic
GetEnumerator over non-generic variant.  Fix code to follow comments.
* tests/gtest-302.cs: New test based on #80249.


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-01-11 11:03:31 UTC (rev 70849)
+++ trunk/mcs/mcs/ChangeLog     2007-01-11 11:52:18 UTC (rev 70850)
@@ -1,3 +1,9 @@
+2007-01-11  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Fix #80249
+       * statement.cs (CollectionForeach.TryType): Prefer generic
+       GetEnumerator over non-generic variant.  Fix code to follow comments.
+
 2007-01-09  Raja R Harinath  <[EMAIL PROTECTED]>
 
        Fix #80446

Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs  2007-01-11 11:03:31 UTC (rev 70849)
+++ trunk/mcs/mcs/statement.cs  2007-01-11 11:52:18 UTC (rev 70850)
@@ -4917,7 +4917,7 @@
                                                        if 
(!TypeManager.IsGenericType (mi.ReturnType))
                                                                continue;
 
-                                                       
Report.SymbolRelatedToPreviousError(t);
+                                                       
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));
@@ -4925,13 +4925,13 @@
                                                }
 
                                                // Always prefer generics 
enumerators
-                                               if 
(TypeManager.IsGenericType(mi.ReturnType))
-                                                       continue;
-
-                                               
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}'",
-                                                       TypeManager.CSharpName 
(t), "enumerable", TypeManager.CSharpSignature (result), 
TypeManager.CSharpSignature (mi));
+                                               if (!TypeManager.IsGenericType 
(mi.ReturnType)) {
+                                                       
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}'",
+                                                                       
TypeManager.CSharpName (t), "enumerable", TypeManager.CSharpSignature (result), 
TypeManager.CSharpSignature (mi));
+                                                       return false;
+                                               }
                                        }
                                        result = mi;
                                        tmp_move_next = move_next;

Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog   2007-01-11 11:03:31 UTC (rev 70849)
+++ trunk/mcs/tests/ChangeLog   2007-01-11 11:52:18 UTC (rev 70850)
@@ -1,3 +1,7 @@
+2007-01-11  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * gtest-302.cs: New test based on #80249.
+
 2007-01-09  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * gtest-301.cs, gtest-301-lib.cs: New tests from #80446.

Added: trunk/mcs/tests/gtest-302.cs
===================================================================
--- trunk/mcs/tests/gtest-302.cs        2007-01-11 11:03:31 UTC (rev 70849)
+++ trunk/mcs/tests/gtest-302.cs        2007-01-11 11:52:18 UTC (rev 70850)
@@ -0,0 +1,20 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+interface ITest : IEnumerable<int> {
+}
+
+class Test : ITest {
+       IEnumerator IEnumerable.GetEnumerator () { throw new Exception (); }
+       IEnumerator<int> IEnumerable<int>.GetEnumerator () { yield break; }
+}
+
+class M {
+       static void Main ()
+       {
+               ITest foo = new Test ();
+               foreach (int i in foo)
+                       Console.WriteLine (i);
+       }
+}


Property changes on: trunk/mcs/tests/gtest-302.cs
___________________________________________________________________
Name: svn:eol-style
   + native

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

Reply via email to