2005-06-03 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / tests / gen-40.cs
1 public interface INode<T>
2 {
3         void Hello (T t);
4 }
5
6 public class Stack<T>
7 {
8         public T TheData;
9         public readonly Foo<T> TheFoo;
10
11         public Stack (T t)
12         {
13                 this.TheData = t;
14                 this.TheFoo = new Foo<T> (t);
15         }
16
17         public INode<T> GetNode ()
18         {
19                 return new Node (this);
20         }
21
22         public Foo<T> GetFoo (T t)
23         {
24                 return new Foo<T> (t);
25         }
26
27         public Bar<T> GetBar (T t)
28         {
29                 return new Bar<T> (t);
30         }
31
32         protected class Node : INode<T>
33         {
34                 public readonly Stack<T> Stack;
35
36                 public Node (Stack<T> stack)
37                 {
38                         this.Stack = stack;
39                 }
40
41                 public void Hello (T t)
42                 {
43                 }
44         }
45
46         public class Foo<T>
47         {
48                 public readonly T Data;
49
50                 public Bar<T> GetBar ()
51                 {
52                         return new Bar<T> (Data);
53                 }
54
55                 public Foo (T t)
56                 {
57                         this.Data = t;
58                 }
59         }
60
61         public class Bar<U>
62         {
63                 public readonly U Data;
64
65                 public Bar (U u)
66                 {
67                         this.Data = u;
68                 }
69
70                 public Foo<T> GetFoo (Stack<T> stack)
71                 {
72                         return stack.TheFoo;
73                 }
74
75                 public class Baz<V>
76                 {
77                         public readonly V Data;
78
79                         public Foo<T> GetFoo (Stack<T> stack)
80                         {
81                                 return new Foo<T> (stack.TheData);
82                         }
83
84                         public Bar<V> GetBar ()
85                         {
86                                 return new Bar<V> (Data);
87                         }
88
89                         public Baz (V v)
90                         {
91                                 this.Data = v;
92                         }
93                 }
94         }
95
96         public void Test ()
97         {
98                 Stack<T>.Foo<T> foo1 = GetFoo (TheData);
99                 Foo<T> foo2 = GetFoo (TheData);
100
101                 Stack<long>.Foo<T> foo3 = new Stack<long>.Foo<T> (TheData);
102                 Stack<long>.Foo<float> foo4 = new Stack<long>.Foo<float> (3.14F);
103
104                 Foo<double> foo5 = new Foo<double> (3.14);
105         }
106 }
107
108 class X
109 {
110         static void Main ()
111         {
112                 Stack<int> stack = new Stack<int> (1);
113                 INode<int> node = stack.GetNode ();
114                 Stack<int>.Foo<int> foo = stack.GetFoo (7);
115                 Stack<int>.Bar<int> bar = stack.GetBar (8);
116         }
117 }