Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/b5bc9d75d52e...9209bf563404
Commit: 9209bf563404b20e7e5704bc88b841c152390b89
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-28 12:08:58 GMT
URL: https://github.com/mono/mono/commit/9209bf563404b20e7e5704bc88b841c152390b89
Better error message when type inference resolves valid types but parameter types still don't match
Changed paths:
M mcs/mcs/ecore.cs
M mcs/mcs/expression.cs
Added paths:
A mcs/errors/cs0162-19.cs
A mcs/errors/cs1503-14.cs
A mcs/errors/cs1503-15.cs
A mcs/errors/cs1503-16.cs
Removed paths:
D mcs/errors/cs0411-15.cs
D mcs/errors/cs0411-7.cs
Added: mcs/errors/cs0162-19.cs
===================================================================
@@ -0,0 +1,14 @@
+// CS0162: Unreachable code detected
+// Line: 12
+// Compiler options: -warnaserror
+
+public class X
+{
+ static void test (int stop)
+ {
+ int pos = 0;
+ do {
+ break;
+ } while (pos < stop);
+ }
+}
Added: mcs/errors/cs1503-14.cs
===================================================================
@@ -0,0 +1,25 @@
+// CS1503: Argument `#2' cannot convert `IContravariant<object>' expression to type `ICovariant<string>'
+// Line: 23
+
+interface IContravariant<in T>
+{
+}
+
+interface ICovariant<out T>
+{
+}
+
+class C
+{
+ public static void Test<T> (ICovariant<T> e1, ICovariant<T> e2)
+ {
+ }
+
+ public static void Main ()
+ {
+ ICovariant<string> a_2 = null;
+ IContravariant<object> b_2 = null;
+
+ Test (a_2, b_2);
+ }
+}
\ No newline at end of file
Renamed: mcs/errors/cs1503-15.cs
===================================================================
@@ -1,5 +1,5 @@
-// CS0411: The type arguments for method `C.Foo<T>(IFoo<T>, IFoo<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
-// Line: 17
+// CS1503: Argument `#2' cannot convert `IFoo<object>' expression to type `IFoo<int>'
+// Line: 18
interface IFoo<in T>
{
Renamed: mcs/errors/cs1503-16.cs
===================================================================
@@ -1,4 +1,4 @@
-// CS0411: The type arguments for method `C.Foo<T>(T, System.Collections.Generic.Comparer<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
+// CS1503: Argument `#2' cannot convert `method group' expression to type `System.Collections.Generic.Comparer<int>'
// Line: 20
using System;
Modified: mcs/mcs/ecore.cs
===================================================================
@@ -5266,7 +5266,7 @@ void ReportOverloadError (ResolveContext rc, MemberSpec best_candidate, IParamet
if (ms.TypeArguments != null)
constr_ok = new ConstraintChecker (rc.MemberContext).CheckAll (ms.GetGenericMethodDefinition (), ms.TypeArguments, ms.Constraints, loc);
- if (ta_count == 0) {
+ if (ta_count == 0 && ms.TypeArguments == null) {
if (custom_errors != null && custom_errors.TypeInferenceFailed (rc, best_candidate))
return;
Modified: mcs/mcs/expression.cs
===================================================================
@@ -6014,7 +6014,17 @@ public override MethodGroupExpr CanReduceLambda (AnonymousMethodBody body)
var emg = MethodGroup as ExtensionMethodGroupExpr;
if (emg != null) {
- return MethodGroupExpr.CreatePredefined (candidate, candidate.DeclaringType, MethodGroup.Location);
+ var mg = MethodGroupExpr.CreatePredefined (candidate, candidate.DeclaringType, MethodGroup.Location);
+ if (candidate.IsGeneric) {
+ var targs = new TypeExpression [candidate.Arity];
+ for (int i = 0; i < targs.Length; ++i) {
+ targs[i] = new TypeExpression (candidate.TypeArguments[i], MethodGroup.Location);
+ }
+
+ mg.SetTypeArguments (null, new TypeArguments (targs));
+ }
+
+ return mg;
}
return MethodGroup;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.