Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / shared-generic-methods.2.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
4
5 namespace GenericSharingTest {
6
7 public class ClassA {}
8 public class ClassB {}
9 public class ClassC {}
10
11 public class GenA<T> {
12         public int genericMethod<M> () {
13                 return 123;
14         }
15
16         public int genericMethodCaller () {
17                 return genericMethod<int> ();
18         }
19 }
20
21 public class main {
22         static bool haveError = false;
23
24         public static void error (string message) {
25                 haveError = true;
26                 Console.WriteLine (message);
27         }
28
29         public static void typeCheck (String method, Object obj, Type t) {
30                 if (obj.GetType () != t)
31                         error ("object from " + method + " should have type " + t.ToString () + " but has type " + obj.GetType ().ToString ());
32         }
33
34         public static int Main ()
35         {
36                 GenA<ClassA> ga = new GenA<ClassA> ();
37                 GenA<GenA<ClassB>> gaab = new GenA<GenA<ClassB>> ();
38
39                 if (ga.genericMethodCaller () != 123)
40                         error ("ga.genericMethodCaller");
41
42                 if (gaab.genericMethodCaller () != 123)
43                         error ("gaab.genericMethodCaller");
44
45                 if (haveError)
46                         return 1;
47                 return 0;
48         }
49 }
50
51 }