2010-06-17 Geoff Norton <gnorton@novell.com>
[mono.git] / mono / tests / shared-generic-methods.2.cs
blob27de2f3d0de9a1ad83f2d0910570156a0430f825
1 using System;
2 using System.Collections.Generic;
3 using System.Reflection;
5 namespace GenericSharingTest {
7 public class ClassA {}
8 public class ClassB {}
9 public class ClassC {}
11 public class GenA<T> {
12 public int genericMethod<M> () {
13 return 123;
16 public int genericMethodCaller () {
17 return genericMethod<int> ();
21 public class main {
22 static bool haveError = false;
24 public static void error (string message) {
25 haveError = true;
26 Console.WriteLine (message);
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 ());
34 public static int Main ()
36 GenA<ClassA> ga = new GenA<ClassA> ();
37 GenA<GenA<ClassB>> gaab = new GenA<GenA<ClassB>> ();
39 if (ga.genericMethodCaller () != 123)
40 error ("ga.genericMethodCaller");
42 if (gaab.genericMethodCaller () != 123)
43 error ("gaab.genericMethodCaller");
45 if (haveError)
46 return 1;
47 return 0;