[mcs] Better detection of null operator inside conditional expression. Fixes #57232
[mono.git] / mcs / tests / gtest-409.cs
index 96aff7aa3397e94ad0ed6f53ab768504ac1fb1b9..8db59d7e48d63650f38af54129943c59971b9e47 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 
 //
-// Parser conditional and cast expression tests
+// parser conditional and cast expression tests
 //
 
 class A<T>
@@ -31,6 +31,18 @@ public class ConditionalParsing
        struct S
        {
        }
+
+       struct MyTestStruct : IDisposable
+       {
+               public void Dispose ()
+               {
+               }
+
+               public static implicit operator MyTestStruct (int i)
+               {
+                       return new MyTestStruct ();
+               }
+       }
        
        void Test_1 (bool a)
        {
@@ -129,6 +141,40 @@ public class ConditionalParsing
                bool? b = Test (1, arg:2);
        }
 
+       void Test_17 ()
+       {
+               {
+                       using (MyTestStruct? mts = (int?) 1)
+                       {
+                       }
+               }
+       }
+
+       void Test_18 (bool b, Action a)
+       {
+               var e = b ? () => { } : a;
+       }
+
+       void Test_19 (int[,] table)
+       {
+               var x = 1 > 0  ? table[5, 1] : 0;
+       }
+
+       void Test_20 ()
+       {
+               var t = (Object)string.Empty;
+       }
+
+       void Test_21 ()
+       {
+               var t = (Int32)sbyte.MaxValue;
+       }
+
+       void Test_22 (bool args)
+       {
+               var x = args ?.2f : -.2f;
+       }
+
        static void Helper<T> (T arg)
        {
        }