2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / gtest-variance-11.cs
blob35a26094a781ac63961f5c358f2d58e17712265e
1 // Compiler options: -langversion:future
3 using System;
5 interface IContravariant<in T>
9 interface ICovariant<out T>
13 class D
15 public static bool Contra<T> (IContravariant<T> e1, IContravariant<T> e2)
17 Console.WriteLine (typeof (T));
18 return typeof (T) == typeof (string);
21 public static bool Covariant<T> (ICovariant<T> e1, ICovariant<T> e2)
23 Console.WriteLine (typeof (T));
24 return typeof (T) == typeof (object);
27 public static int Main ()
29 ICovariant<object> a = null;
30 ICovariant<string> b = null;
31 if (!Covariant (a, b))
32 return 1;
34 IContravariant<string> a_1 = null;
35 IContravariant<object> b_1 = null;
36 if (!Contra (a_1, b_1))
37 return 2;
39 return 0;