summaryrefslogtreecommitdiff
path: root/mono/mini/gshared.cs
diff options
context:
space:
mode:
Diffstat (limited to 'mono/mini/gshared.cs')
-rw-r--r--mono/mini/gshared.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/mono/mini/gshared.cs b/mono/mini/gshared.cs
index c52dccfe84..8ed2dbe2bf 100644
--- a/mono/mini/gshared.cs
+++ b/mono/mini/gshared.cs
@@ -1291,11 +1291,21 @@ public class Tests
}
}
+ struct ConsStructThrow : IConstrained {
+ public void foo () {
+ throw new Exception ();
+ }
+
+ public void foo_ref_arg (string s) {
+ }
+ }
+
interface IFaceConstrained {
void constrained_void_iface_call<T, T2>(T t, T2 t2) where T2 : IConstrained;
void constrained_void_iface_call_ref_arg<T, T2>(T t, T2 t2) where T2 : IConstrained;
void constrained_void_iface_call_gsharedvt_arg<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T>;
T constrained_iface_call_gsharedvt_ret<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T>;
+ T2 constrained_normal_call<T, T2>(T t, T2 t2) where T2 : VClass;
}
class ClassConstrained : IFaceConstrained {
@@ -1318,6 +1328,18 @@ public class Tests
public T constrained_iface_call_gsharedvt_ret<T, T2, T3>(T t, T2 t2, T3 t3) where T2 : IConstrained<T> {
return t2.foo_gsharedvt_ret (t);
}
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public T2 constrained_normal_call<T, T2>(T t, T2 t2) where T2 : VClass {
+ /* This becomes a constrained call even through 't2' is forced to be a reference type by the constraint */
+ return (T2)t2.foo (5);
+ }
+ }
+
+ class VClass {
+ public virtual VClass foo (int i) {
+ return this;
+ }
}
public static int test_0_constrained_void_iface_call () {
@@ -1343,6 +1365,17 @@ public class Tests
return 0;
}
+ public static int test_0_constrained_eh () {
+ var s2 = new ConsStructThrow () { };
+ try {
+ IFaceConstrained c = new ClassConstrained ();
+ c.constrained_void_iface_call<int, ConsStructThrow> (1, s2);
+ return 1;
+ } catch (Exception) {
+ return 0;
+ }
+ }
+
public static int test_0_constrained_void_iface_call_gsharedvt_arg () {
// This tests constrained calls through interfaces with one gsharedvt arg, like IComparable<T>.CompareTo ()
IFaceConstrained c = new ClassConstrained ();
@@ -1378,6 +1411,14 @@ public class Tests
return 0;
}
+ public static int test_0_constrained_normal_call () {
+ IFaceConstrained c = new ClassConstrained ();
+
+ var o = new VClass ();
+ var res = c.constrained_normal_call<int, VClass> (1, o);
+ return res == o ? 0 : 1;
+ }
+
public static async Task<T> FooAsync<T> (int i, int j) {
Task<int> t = new Task<int> (delegate () { return 42; });
var response = await t;