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