[mcs] Null coalescing over typed null constants.
authorMarek Safar <marek.safar@gmail.com>
Tue, 22 Nov 2016 16:01:15 +0000 (17:01 +0100)
committerMarek Safar <marek.safar@gmail.com>
Tue, 22 Nov 2016 16:02:38 +0000 (17:02 +0100)
mcs/mcs/nullable.cs
mcs/tests/gtest-621.cs
mcs/tests/ver-il-net_4_x.xml

index cce1f8419ce4c470eb5880c529786d337c7f693b..93314df322ad9c202cbc1667077a1f050738f27e 100644 (file)
@@ -1210,7 +1210,7 @@ namespace Mono.CSharp.Nullable
                                                //
                                                // Special case null ?? null
                                                //
-                                               if (right.IsNull && ltype == right.Type)
+                                               if (right is NullLiteral && ltype == right.Type)
                                                        return null;
 
                                                return ReducedExpression.Create (lc != null ? right : left, this, false);
index cfff301328ed9d824a550f1c2f9811cc16c7d850..6444cb7918ed1d9497388cba8fe6c9bf5ad10a5b 100644 (file)
@@ -26,4 +26,10 @@ class X
                        
                return 0;
        }
+
+       const Action cf = null;
+       void Foo (Action f)
+       {
+               var x = f ?? cf;
+       }
 }
\ No newline at end of file
index ddb13732d045f93741bf1e5899a1ef29903e6590..4502b9b63be1cc41c153df1602b9002b477a4fd1 100644 (file)
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
       </method>
+      <method name="Void Foo(System.Action)" attrs="129">
+        <size>4</size>
+      </method>
     </type>
   </test>
   <test name="gtest-622.cs">