using System;
using System.Collections.Generic;
+// Generics mutate tests
+
class Disposable<T> : IDisposable
{
public void Dispose ()
}
}
+interface IFoo<TOne,TTwo>
+{
+}
+
+class CA<T>
+{
+ public struct Nested
+ {
+ public static readonly T Value;
+ public readonly T Value2;
+ }
+}
+
class Test
{
static Func<T[]> For<T> (List<T> list)
};
}
+ static Func<Type> TypeOf<T> (T t)
+ {
+ T l = t;
+ return () => {
+ l = t;
+ var e = typeof (Disposable <T>);
+ e = typeof (Disposable <>);
+ e = typeof (IFoo <,>);
+ return typeof (T);
+ };
+ }
+
static Func<T> Do<T> (T t)
{
T l = t;
};
}
+ public void ArrayMutate<T> (T[] array)
+ {
+ int r = 4;
+ Action<int> anonMeth = delegate (int slc) {
+ long[] idx = new long[] { 0, 0 };
+ for (int i = 0; i < r; i++) {
+ idx [0] = i;
+ }
+ };
+ }
+
+ static Func<T[][]> ArrayMultiMutate<T> (T[][] array)
+ {
+ return () => {
+ for (int i = 0; i < 3; i++) {
+ array [i][i] = default (T);
+ }
+
+ return array;
+ };
+ }
+
+ static Func<T[]> NestedTypeMutate<T> ()
+ {
+ var local = new CA<T>.Nested ();
+ return () => {
+ return new [] { CA<T>.Nested.Value, local.Value2 };
+ };
+ }
+
public static int Main ()
{
if (For (new List<int> { 5, 10 })() [1] != 10)
var t9 = ForForeach (new [] { 4, 1 });
if (t9 ()[0] != 4)
return 9;
+
+ var t10 = ArrayMultiMutate (new string [][] { new string [] { "a", "b", "c" }, new string [] { "1", "2", "3" }, new string [] { "A", "B", "C" }});
+ if (t10 () [2] [2] != null)
+ return 10;
+
+ var t11 = TypeOf ("b");
+ if (t11 () != typeof (string))
+ return 11;
+ var t12 = NestedTypeMutate<ulong> ()();
+ if (t12 [0] != 0 || t12 [1] != 0)
+ return 12;
+
Console.WriteLine ("OK");
return 0;
}
-}
\ No newline at end of file
+}