[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / tests / gtest-602.cs
1 using System.Collections.Generic;
2 using System;
3
4 public class Factory<TKey, TBase>
5 {
6         delegate T InstantiateMethod<T> ();
7
8         Dictionary<TKey, InstantiateMethod<TBase>> _Products = new Dictionary<TKey, InstantiateMethod<TBase>> ();
9
10         public void Register<T> (TKey key) where T : TBase, new()
11         {
12                 _Products.Add (key, Constructor<T>);
13         }
14
15         public TBase Produce (TKey key)
16         {
17                 return _Products [key] ();
18         }
19
20         static TBase Constructor<T> () where T : TBase, new()
21         {
22                 return new T ();
23         }
24 }
25
26 class BaseClass
27 {
28 }
29
30 class ChildClass1 : BaseClass
31 {
32 }
33
34 class ChildClass2 : BaseClass
35 {
36 }
37
38 class TestClass
39 {
40         public static int Main ()
41         {
42                 var factory = new Factory<byte, BaseClass> ();
43                 factory.Register<ChildClass1> (1);
44                 factory.Register<ChildClass2> (2);
45
46                 if (factory.Produce (1).GetType () != typeof (ChildClass1))
47                         return 1;
48
49                 if (factory.Produce (2).GetType () != typeof (ChildClass2))
50                         return 2;
51
52                 return 0;
53         }
54 }