return 0;
}
+ public static int test_0_nullable_ldflda () {
+ return GenericClass<string>.BIsAClazz == false ? 0 : 1;
+ }
+
public struct GenericStruct<T> {
public T t;
{
return x [index];
}
+
+ protected static T NullB = default(T);
+ private static Nullable<bool> _BIsA = null;
+ public static bool BIsAClazz {
+ get {
+ _BIsA = false;
+ return _BIsA.Value;
+ }
+ }
}
public class MRO : MarshalByRefObject {
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<object> () != o)
return 1;
return the_type == typeof (string) ? 0 : 1;
}
+ public static int test_0_throw_dead_this () {
+ new Foo<string> ("").throw_dead_this ();
+ return 0;
+ }
+
+ public static int test_0_generic_virtual_on_interfaces () {
+ Foo<string>.count1 = 0;
+ Foo<string>.count2 = 0;
+ Foo<string>.count3 = 0;
+
+ IFoo f = new Foo<string> ("");
+ for (int i = 0; i < 1000; ++i) {
+ f.Bar <int> ();
+ f.Bar <string> ();
+ f.NonGeneric ();
+ }
+
+ if (Foo<string>.count1 != 1000)
+ return 1;
+ if (Foo<string>.count2 != 1000)
+ return 2;
+ if (Foo<string>.count3 != 1000)
+ return 3;
+
+ VirtualInterfaceCallFromGenericMethod<long> (f);
+
+ return 0;
+ }
+
+ public static void VirtualInterfaceCallFromGenericMethod <T> (IFoo f) {
+ f.Bar <T> ();
+ }
+
public static Type the_type;
public void ldvirtftn<T> () {
the_type = typeof (T);
}
- public class Foo<T1>
+ public interface IFoo {
+ void NonGeneric ();
+ object Bar<T>();
+ }
+
+ public class Foo<T1> : IFoo
{
public Foo(T1 t1)
{
}
}
+ public void throw_dead_this () {
+ try {
+ new SomeClass().ThrowAnException();
+ }
+ catch {
+ }
+ }
+
public T1 get_default () {
return default (T1);
}
GenericEvent (this);
}
- }
+ public static int count1, count2, count3;
- public interface IMyHandler {
- object Bar<T>();
+ public void NonGeneric () {
+ count3 ++;
+ }
+
+ public object Bar <T> () {
+ 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<T>() {
return o;
}