--- /dev/null
+// 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);
+ }
+}
+++ /dev/null
-// 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
-
-interface IFoo<in T>
-{
-}
-
-class C
-{
- public static void Foo<T> (IFoo<T> e1, IFoo<T> e2)
- {
- }
-
- public static void Main ()
- {
- IFoo<int> a = null;
- IFoo<object> b = null;
- Foo (a, b);
- }
-}
+++ /dev/null
-// 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
-// Line: 20
-
-using System;
-using System.Collections.Generic;
-
-public class C
-{
- static void Foo<T>(T t, Comparer<T> tc)
- {
- }
-
- static int Compare (int a, int b)
- {
- return -1;
- }
-
- public static void Main ()
- {
- Foo (1, Compare);
- }
-}
--- /dev/null
+// 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
--- /dev/null
+// CS1503: Argument `#2' cannot convert `IFoo<object>' expression to type `IFoo<int>'
+// Line: 18
+
+interface IFoo<in T>
+{
+}
+
+class C
+{
+ public static void Foo<T> (IFoo<T> e1, IFoo<T> e2)
+ {
+ }
+
+ public static void Main ()
+ {
+ IFoo<int> a = null;
+ IFoo<object> b = null;
+ Foo (a, b);
+ }
+}
--- /dev/null
+// CS1503: Argument `#2' cannot convert `method group' expression to type `System.Collections.Generic.Comparer<int>'
+// Line: 20
+
+using System;
+using System.Collections.Generic;
+
+public class C
+{
+ static void Foo<T>(T t, Comparer<T> tc)
+ {
+ }
+
+ static int Compare (int a, int b)
+ {
+ return -1;
+ }
+
+ public static void Main ()
+ {
+ Foo (1, Compare);
+ }
+}
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;
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;