New test, formerly known as gen-51.cs.
[mono.git] / mcs / errors / gcs0309-3.cs
1 // CS0309: The type 'B' must be convertible to 'A' in order to use it
2 // as parameter 'T' in the generic type or method 'Foo<T>'
3 // Line: 35
4 using System;
5
6 public class Foo<T>
7         where T : A
8 {
9         public void Test (T t)
10         {
11                 Console.WriteLine (t);
12                 Console.WriteLine (t.GetType ());
13                 t.Hello ();
14         }
15 }
16
17 public class A
18 {
19         public void Hello ()
20         {
21                 Console.WriteLine ("Hello World");
22         }
23 }
24
25 public class B
26 {
27         public static implicit operator A (B b)
28         {
29                 return new A ();
30         }
31 }
32
33 class X
34 {
35         Foo<B> b;
36
37         static void Main ()
38         {
39         }
40 }