Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic-inlining.2.cs
1 using System.Collections.Generic;
2 using System.Runtime.CompilerServices;
3
4 public class Gen<T> {
5         public T[] method () {
6                 return new T[3];
7         }
8
9         public static T[] staticMethod () {
10                 return new T[3];
11         }
12
13         public S[] genericMethod<S> () {
14                 return new S[3];
15         }
16 }
17
18 public class main {
19         static bool callMethod<T> (Gen<T> g) {
20                 return g.method ().GetType () == typeof (T[]);
21         }
22
23         static bool callStaticMethod<T> () {
24                 return Gen<T>.staticMethod ().GetType () == typeof (T[]);
25         }
26
27         static bool callGenericMethod<T,S> (Gen<T> g) {
28                 return g.genericMethod<S> ().GetType () == typeof (S[]);
29         }
30
31         [MethodImpl (MethodImplOptions.NoInlining)]
32         static bool work<T,S> () {
33                 Gen<T> g = new Gen<T> ();
34
35                 if (!callMethod<T> (g))
36                         return false;
37                 if (!callStaticMethod<T> ())
38                         return false;
39                 if (!callGenericMethod<T,S> (g))
40                         return false;
41                 return true;
42         }
43
44         public static int Main () {
45                 if (!work<string,string> ())
46                         return 1;
47                 if (!work<int,int> ())
48                         return 1;
49                 if (!work<string,int> ())
50                         return 1;
51                 if (!work<int,string> ())
52                         return 1;
53                 return 0;
54         }
55 }