[ilasm] Don't break arguments compatiblity
[mono-project.git] / mcs / tests / gtest-117.cs
blobe1e54267b8e7f454420a630b289282625daf0a98
1 // Compiler options: -warnaserror
3 using System;
5 enum E { Item };
7 public interface IFoo<T>
8 { }
10 public class Foo<T>
12 public static bool Test (T x)
14 return x is IFoo<T>;
17 public static bool Test ()
19 T t = default (T);
20 return t is int;
23 public static bool TestB ()
25 T t = default (T);
26 return t is int?;
30 class Y<T> where T : struct
32 public bool Foo ()
34 object o = null;
35 return o is System.Nullable <T>;
39 class X
41 public static bool TestA (object o)
43 return o is int?;
46 public static bool TestB<T> (T o)
48 return o is int[];
51 public static int TestC ()
53 int? i = null;
54 if (i is int) {
55 return (int) i;
58 return 3;
61 static bool Check1 (E? e)
63 return e is Enum;
66 static bool Check2<T> (E e) where T : struct
68 return e is T;
71 public static int Main ()
73 if (Foo<int>.Test (3))
74 return 1;
76 if (!Foo<int>.Test())
77 return 2;
79 // False expected int? != null
80 if (Foo<int?>.TestB())
81 return 3;
83 int? i = 0;
84 if (!TestA(i))
85 return 4;
87 int[] a = new int[0];
88 if (!TestB(a))
89 return 5;
91 if (TestC () != 3)
92 return 6;
94 if (Check1 (null))
95 return 7;
97 if (!Check1 (E.Item))
98 return 8;
100 if (Check2<int> (E.Item))
101 return 9;
103 Console.WriteLine ("OK");
104 return 0;