[ilasm] Don't break arguments compatiblity
[mono-project.git] / mcs / tests / gtest-variance-11.cs
blob110044f0a5d8d87f4a3bfddf3da316ffcd4d10e1
1 using System;
3 interface IContravariant<in T>
7 interface ICovariant<out T>
11 class D
13 public static bool Contra<T> (IContravariant<T> e1, IContravariant<T> e2)
15 Console.WriteLine (typeof (T));
16 return typeof (T) == typeof (string);
19 public static bool Covariant<T> (ICovariant<T> e1, ICovariant<T> e2)
21 Console.WriteLine (typeof (T));
22 return typeof (T) == typeof (object);
25 public static bool CovContCont<T> (ICovariant<T> e1, IContravariant<T> e2, IContravariant<T> e3)
27 Console.WriteLine (typeof (T));
28 return typeof (T) == typeof (string);
31 public static bool ContCovContCov<T> (IContravariant<T> e1, ICovariant<T> e2, IContravariant<T> e3, ICovariant<T> e4)
33 Console.WriteLine (typeof (T));
34 return typeof (T) == typeof (string);
37 public static bool CovCovCont<T> (ICovariant<T> e1, ICovariant<T> e2, IContravariant<T> e3)
39 Console.WriteLine (typeof (T));
40 return typeof (T) == typeof (string);
43 public static int Main ()
46 ICovariant<object> a = null;
47 ICovariant<string> b = null;
48 if (!Covariant (a, b))
49 return 1;
51 IContravariant<string> a_1 = null;
52 IContravariant<object> b_1 = null;
53 if (!Contra (a_1, b_1))
54 return 2;
56 ICovariant<string> a_2 = null;
57 IContravariant<object> b_2 = null;
58 IContravariant<string> c_2 = null;
59 if (!CovContCont (a_2, b_2, c_2))
60 return 3;
62 IContravariant<object> a_3 = null;
63 ICovariant<string> b_3 = null;
64 IContravariant<string> c_3 = null;
65 ICovariant<string> d_3 = null;
66 if (!ContCovContCov (a_3, b_3, c_3, d_3))
67 return 4;
69 Console.WriteLine ("ok");
70 return 0;