Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic_type_definition_encoding.2.cs
1 using System.Collections.Generic;
2 using System;
3
4 class C<X,Y>
5 {
6         class Q<A,B>
7         {
8                 public  Type[] apply (C<X,Y> t)
9                 {
10                         return t.bar<A,B>();
11                 }
12         }
13
14         public  Type[] foo<A,B> ()
15         {
16                 Q<A,B> q = new Q<A,B>();
17                 return q.apply(this);
18         }
19
20         public Type[] bar<A,B> ()
21         {
22                 return new Type[] { typeof(X), typeof(Y), typeof(A), typeof(B) };
23         }
24 }
25
26
27 class TypeofTest {
28         public bool Bla() {
29                 Type t = typeof (Dictionary<,>);
30                 Type t2 = typeof (C<,>);
31                 return t.IsGenericTypeDefinition && t2.IsGenericTypeDefinition;
32         }       
33 }
34
35 class TypeofTest2<X,Y> {
36         public bool Bla() {
37                 Type t = typeof (Dictionary<,>);
38                 Type t2= typeof (C<,>);
39                 return t.IsGenericTypeDefinition && t2.IsGenericTypeDefinition;
40         }       
41 }
42
43 class Driver {
44         public static int Main () {
45                 C<int,string> c = new C<int,string>();
46                 Type[] types = c.foo<float,string> ();
47                 foreach (Type t in types)
48                         Console.WriteLine (t);
49                 if (types [0] != typeof (int))
50                         return 1;
51                 if (types [1] != typeof (string))
52                         return 2;
53                 if (types [2] != typeof (float))
54                         return 3;
55                 if (types [3] != typeof (string))
56                         return 4;
57
58                 if (!new TypeofTest().Bla())
59                         return 5;
60                 if (!new TypeofTest2<int, double>().Bla())
61                         return 6;
62
63                 return 0;
64         }
65 }