copied mono-api-diff.cs from mono-2-2 branch so new patch can be applied and history...
[mono.git] / mcs / tests / gtest-variance-11.cs
1 // Compiler options: -langversion:future
2
3 using System;
4
5 interface IContravariant<in T>
6 {
7 }
8
9 interface ICovariant<out T>
10 {
11 }
12
13 class D
14 {
15         public static bool Contra<T> (IContravariant<T> e1, IContravariant<T> e2)
16         {
17                 Console.WriteLine (typeof (T));
18                 return typeof (T) == typeof (string);
19         }
20         
21         public static bool Covariant<T> (ICovariant<T> e1, ICovariant<T> e2)
22         {
23                 Console.WriteLine (typeof (T));
24                 return typeof (T) == typeof (object);
25         }
26         
27         public static int Main ()
28         {
29                 ICovariant<object> a = null;
30                 ICovariant<string> b = null;
31                 if (!Covariant (a, b))
32                         return 1;
33                 
34                 IContravariant<string> a_1 = null;
35                 IContravariant<object> b_1 = null;
36                 if (!Contra (a_1, b_1))
37                         return 2;
38                 
39                 return 0;
40         }
41 }