[mcs] Fix crash during ambiguous implementation of the query pattern error reporting...
authorMarek Safar <marek.safar@gmail.com>
Fri, 24 Jul 2015 15:29:53 +0000 (17:29 +0200)
committerMarek Safar <marek.safar@gmail.com>
Fri, 24 Jul 2015 15:29:53 +0000 (17:29 +0200)
mcs/errors/cs1940-2.cs [new file with mode: 0644]
mcs/mcs/linq.cs

diff --git a/mcs/errors/cs1940-2.cs b/mcs/errors/cs1940-2.cs
new file mode 100644 (file)
index 0000000..70db3b6
--- /dev/null
@@ -0,0 +1,29 @@
+// CS1940: Ambiguous implementation of the query pattern `Select' for source type `string[]'
+// Line: 11
+
+using System;
+using System.Collections.Generic;
+
+class Multiple
+{
+       public static void Main ()
+       {
+               var q = from x in new [] { "a", "b", "c" } select x;
+       }
+}
+
+static class Y
+{
+       public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
+       {
+               return null;
+       }
+}
+
+static class X
+{
+       public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
+       {
+               return null;
+       }
+}
\ No newline at end of file
index 7f19c2d89b35524f73e49b9b00c4029326fb4276..40c500d365ef131b253ca9fa3ae78b7c10b47a68 100644 (file)
@@ -96,10 +96,13 @@ namespace Mono.CSharp.Linq
 
                        bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
                        {
+                               var emg = mg as ExtensionMethodGroupExpr;
+                               var type = emg == null ? mg.InstanceExpression : emg.ExtensionExpression;
+
                                ec.Report.SymbolRelatedToPreviousError (best);
                                ec.Report.SymbolRelatedToPreviousError (ambiguous);
                                ec.Report.Error (1940, loc, "Ambiguous implementation of the query pattern `{0}' for source type `{1}'",
-                                       best.Name, mg.InstanceExpression.GetSignatureForError ());
+                                       best.Name, type.Type.GetSignatureForError ());
                                return true;
                        }