X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftests%2Ftest-null-operator-04.cs;h=c28aa178ceb5520a50362fbcb39e5c8a26dbcf56;hb=56b3c007f428d93b7f230d58744393ad69e4ca63;hp=6796920d3faa893b6cdf6f4a6b038fd55b51da12;hpb=59d2397abc90def0d843c124e3a5c81c40b6cbd2;p=mono.git diff --git a/mcs/tests/test-null-operator-04.cs b/mcs/tests/test-null-operator-04.cs index 6796920d3fa..c28aa178ceb 100644 --- a/mcs/tests/test-null-operator-04.cs +++ b/mcs/tests/test-null-operator-04.cs @@ -1,14 +1,55 @@ using System; -public class D +interface IFoo { - void Foo () + T Call (); +} + +class C1 +{ + public void Foo (IFoo t) where T : class { + t?.Call (); + var x = t?.Call (); } - public static void Main() + public void Foo2 (IFoo t) + { + t?.Call (); + } +} + +class C2 where T : class +{ + C2 i; + T field; + + public void Foo () { - D d = null; - Action a = d?.Foo; + var x = i?.field; } } + +class Program +{ + static void Test(Func func) where T : struct + { + var r = func?.Invoke (); + } + + static void Test2(Func func) + { + func?.Invoke (); + } + + static void Main() + { + new C1 ().Foo (null); + new C1 ().Foo2 (null); + + new C2 ().Foo (); + + Test (() => 1); + Test (() => 2); + } +} \ No newline at end of file