+
+ struct Record : Foo2<Record>.IRecord {
+ int counter;
+ int Foo2<Record>.IRecord.DoSomething () {
+ return counter++;
+ }
+ }
+
+ class Foo2<T> where T : Foo2<T>.IRecord {
+ public interface IRecord {
+ int DoSomething ();
+ }
+
+ public static int Extract (T[] t) {
+ return t[0].DoSomething ();
+ }
+ }
+
+ class Foo3<T> where T : IComparable {
+ public static int CompareTo (T[] t) {
+ // This is a constrained call to Enum.CompareTo ()
+ return t[0].CompareTo (t [0]);
+ }
+ }
+
+ public static int test_1_regress_constrained_iface_call_7571 () {
+ var r = new Record [10];
+ Foo2<Record>.Extract (r);
+ return Foo2<Record>.Extract (r);
+ }
+
+ enum ConstrainedEnum {
+ Val = 1
+ }
+
+ public static int test_0_regress_constrained_iface_call_enum () {
+ var r = new ConstrainedEnum [10];
+ return Foo3<ConstrainedEnum>.CompareTo (r);
+ }
+
+ public interface IFoo2 {
+ void MoveNext ();
+ }
+
+ public struct Foo2 : IFoo2 {
+ public void MoveNext () {
+ }
+ }
+
+ public static Action Dingus (ref Foo2 f) {
+ return new Action (f.MoveNext);
+ }
+
+ public static int test_0_delegate_unbox_full_aot () {
+ Foo2 foo = new Foo2 ();
+ Dingus (ref foo) ();
+ return 0;
+ }
+
+ public static int test_0_arrays_ireadonly () {
+ int[] arr = new int [10];
+ for (int i = 0; i < 10; ++i)
+ arr [i] = i;
+ IReadOnlyList<int> a = (IReadOnlyList<int>)(object)arr;
+ if (a.Count != 10)
+ return 1;
+ if (a [0] != 0)
+ return 2;
+ if (a [1] != 1)
+ return 3;
+ return 0;
+ }
+
+ public static int test_0_volatile_read_write () {
+ string foo = "ABC";
+ Volatile.Write (ref foo, "DEF");
+ return Volatile.Read (ref foo) == "DEF" ? 0 : 1;
+ }
+
+ // FIXME: Doesn't work with --regression as Interlocked.Add(ref long) is only implemented as an intrinsic
+#if FALSE
+ public static async Task<T> FooAsync<T> (int i, int j) {
+ Task<int> t = new Task<int> (delegate () { Console.WriteLine ("HIT!"); return 0; });
+ var response = await t;
+ return default(T);
+ }
+
+ public static int test_0_fullaot_generic_async () {
+ Task<string> t = FooAsync<string> (1, 2);
+ t.RunSynchronously ();
+ return 0;
+ }
+#endif
+
+ public static int test_0_delegate_callvirt_fullaot () {
+ Func<string> f = delegate () { return "A"; };
+ var f2 = (Func<Func<string>, string>)Delegate.CreateDelegate (typeof
+(Func<Func<string>, string>), null, f.GetType ().GetMethod ("Invoke"));
+
+ var s = f2 (f);
+ return s == "A" ? 0 : 1;
+ }
+
+ public interface ICovariant<out R>
+ {
+ }
+
+ // Deleting the `out` modifier from this line stop the problem
+ public interface IExtCovariant<out R> : ICovariant<R>
+ {
+ }
+
+ public class Sample<R> : ICovariant<R>
+ {
+ }
+
+ public interface IMyInterface
+ {
+ }
+
+ public static int test_0_variant_cast_cache () {
+ object covariant = new Sample<IMyInterface>();
+
+ var foo = (ICovariant<IMyInterface>)(covariant);
+
+ try {
+ var extCovariant = (IExtCovariant<IMyInterface>)covariant;
+ return 1;
+ } catch {
+ return 0;
+ }
+ }
+}
+
+#if !MOBILE
+class GenericsTests : Tests
+{