[runtime] Don't insta-fail when a faulty COM type is encountered. (#5616)
[mono.git] / mcs / tests / test-null-operator-04.cs
index 6796920d3faa893b6cdf6f4a6b038fd55b51da12..c28aa178ceb5520a50362fbcb39e5c8a26dbcf56 100644 (file)
@@ -1,14 +1,55 @@
 using System;
 
-public class D
+interface IFoo<T>
 {
-       void Foo ()
+       T Call ();
+}
+
+class C1
+{
+       public void Foo<T> (IFoo<T> t) where T : class
        {
+               t?.Call ();
+               var x = t?.Call ();
        }
 
-       public static void Main()
+       public void Foo2<T> (IFoo<T> t)
+       {
+               t?.Call ();
+       }       
+}
+
+class C2<T> where T : class
+{
+       C2<T> i;
+       T field;
+
+       public void Foo ()
        {
-               D d = null;
-               Action a = d?.Foo;
+               var x = i?.field;
        }
 }
+
+class Program
+{
+       static void Test<T>(Func<T> func) where T : struct
+       {
+               var r = func?.Invoke ();
+       }
+
+       static void Test2<T>(Func<T> func)
+       {
+               func?.Invoke ();
+       }
+
+       static void Main()
+       {
+               new C1 ().Foo<Program> (null);
+               new C1 ().Foo2<Program> (null);
+
+               new C2<string> ().Foo ();
+
+               Test (() => 1);
+               Test (() => 2);
+       }
+}
\ No newline at end of file