X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fgenerics.cs;h=f7c8393e77fa601a0d4bdc481c9a6704905957fd;hb=409cc50c9c94638819abc1d9a1b921b518313807;hp=1780be65f0381ffbdf8bda2fea6246d8c6ee6ba7;hpb=33028b1a2c0d0345efc3639f3b33d74dc96daf62;p=mono.git diff --git a/mono/mini/generics.cs b/mono/mini/generics.cs index 1780be65f03..f7c8393e77f 100644 --- a/mono/mini/generics.cs +++ b/mono/mini/generics.cs @@ -240,6 +240,10 @@ class Tests { return 0; } + public static int test_0_nullable_ldflda () { + return GenericClass.BIsAClazz == false ? 0 : 1; + } + public struct GenericStruct { public T t; @@ -285,6 +289,15 @@ class Tests { { return x [index]; } + + protected static T NullB = default(T); + private static Nullable _BIsA = null; + public static bool BIsAClazz { + get { + _BIsA = false; + return _BIsA.Value; + } + } } public class MRO : MarshalByRefObject { @@ -319,7 +332,7 @@ class Tests { public static int test_0_generic_virtual_call_on_vtype_unbox () { object o = new Object (); - IMyHandler h = new Handler(o); + IFoo h = new Handler(o); if (h.Bar () != o) return 1; @@ -383,6 +396,39 @@ class Tests { return the_type == typeof (string) ? 0 : 1; } + public static int test_0_throw_dead_this () { + new Foo ("").throw_dead_this (); + return 0; + } + + public static int test_0_generic_virtual_on_interfaces () { + Foo.count1 = 0; + Foo.count2 = 0; + Foo.count3 = 0; + + IFoo f = new Foo (""); + for (int i = 0; i < 1000; ++i) { + f.Bar (); + f.Bar (); + f.NonGeneric (); + } + + if (Foo.count1 != 1000) + return 1; + if (Foo.count2 != 1000) + return 2; + if (Foo.count3 != 1000) + return 3; + + VirtualInterfaceCallFromGenericMethod (f); + + return 0; + } + + public static void VirtualInterfaceCallFromGenericMethod (IFoo f) { + f.Bar (); + } + public static Type the_type; public void ldvirtftn () { @@ -396,7 +442,12 @@ class Tests { the_type = typeof (T); } - public class Foo + public interface IFoo { + void NonGeneric (); + object Bar(); + } + + public class Foo : IFoo { public Foo(T1 t1) { @@ -419,6 +470,14 @@ class Tests { } } + public void throw_dead_this () { + try { + new SomeClass().ThrowAnException(); + } + catch { + } + } + public T1 get_default () { return default (T1); } @@ -433,19 +492,37 @@ class Tests { GenericEvent (this); } - } + public static int count1, count2, count3; - public interface IMyHandler { - object Bar(); + public void NonGeneric () { + count3 ++; + } + + public object Bar () { + if (typeof (T) == typeof (int)) + count1 ++; + else if (typeof (T) == typeof (string)) + count2 ++; + return null; + } } - struct Handler : IMyHandler { + public class SomeClass { + public void ThrowAnException() { + throw new Exception ("Something went wrong"); + } + } + + struct Handler : IFoo { object o; public Handler(object o) { this.o = o; } + public void NonGeneric () { + } + public object Bar() { return o; }