Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / gshared.cs
index e4323480388d18ed54d50e046ddc014aedb50217..75ea14aad6a91463ecc7f3ba0eb2769e97f7be1d 100644 (file)
@@ -1677,6 +1677,8 @@ public class Tests
                                   uint i1, uint i2, uint i3, uint i4);
                int Structs (T t, int dummy1, int a2, int a3, int a4, int a5, int a6, int a7, int dummy8,
                                         BStruct s);
+               void Generic<T2> (T t, T2[] arr, int dummy1, int a2, int a3, int a4, int a5, int a6, int a7, int dummy8,
+                                                 T2 i1, T2 i2, T2 i3, T2 i4);
        }
 
        class Foo3<T> : IFoo3<T> {
@@ -1708,6 +1710,13 @@ public class Tests
                                                        BStruct s) {
                        return s.a + s.b + s.c + s.d;
                }
+
+               public void Generic<T2> (T t, T2[] arr, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, T2 i1, T2 i2, T2 i3, T2 i4) {
+                       arr [0] = i1;
+                       arr [1] = i2;
+                       arr [2] = i3;
+                       arr [3] = i4;
+               }
        }
 
        // Passing small normal arguments on the stack
@@ -1731,6 +1740,10 @@ public class Tests
                int res6 = o.UInts (new EmptyStruct (), 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4);
                if (res6 != 10)
                        return 6;
+               int[] arr = new int [4];
+               o.Generic<int> (new EmptyStruct (), arr, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4);
+               if (arr [0] != 1 || arr [1] != 2 || arr [2] != 3 || arr [3] != 4)
+                       return 7;
                return 0;
        }
 
@@ -1810,6 +1823,19 @@ public class Tests
                }
        }
 
+       struct StructTest : IFaceTest {
+
+               int i;
+
+               public StructTest (int arg) {
+                       i = arg;
+               }
+
+               public int iface_method () {
+                       return i;
+               }
+       }
+
        // Test constrained calls on an interface made from gsharedvt methods
        public static int test_42_gsharedvt_constrained_iface () {
                IFaceConstrainedIFace obj = new ConstrainedIFace ();
@@ -1817,6 +1843,12 @@ public class Tests
                return obj.foo<IFaceTest, int> (ref t);
        }
 
+       public static int test_42_gsharedvt_constrained_iface_vtype () {
+               IFaceConstrainedIFace obj = new ConstrainedIFace ();
+               IFaceTest t = new StructTest (42);
+               return obj.foo<IFaceTest, int> (ref t);
+       }
+
        // Sign extension tests
        // 0x55   == 85    == 01010101
        // 0xAA   == 170   == 10101010
@@ -1959,6 +1991,32 @@ public class Tests
                gsharedvt_vphi (0);
                return 0;
        }
+
+       struct AStruct3<T1, T2, T3> {
+               T1 t1;
+               T2 t2;
+               T3 t3;
+       }
+
+       interface IFaceIsRef {
+               bool is_ref<T> ();
+       }
+
+       class ClassIsRef : IFaceIsRef {
+               [MethodImplAttribute (MethodImplOptions.NoInlining)]
+               public bool is_ref<T> () {
+                       return RuntimeHelpers.IsReferenceOrContainsReferences<T> ();
+               }
+       }
+
+       public static int test_0_isreference_intrins () {
+               IFaceIsRef iface = new ClassIsRef ();
+               if (iface.is_ref<AStruct3<int, int, int>> ())
+                       return 1;
+               if (!iface.is_ref<AStruct3<string, int, int>> ())
+                       return 2;
+               return 0;
+       }
 }
 
 // #13191