of course we can test bool equality
authorJb Evain <jbevain@gmail.com>
Thu, 5 Jun 2008 11:41:23 +0000 (11:41 -0000)
committerJb Evain <jbevain@gmail.com>
Thu, 5 Jun 2008 11:41:23 +0000 (11:41 -0000)
svn path=/trunk/mcs/; revision=104990

mcs/class/System.Core/System.Linq.Expressions/Expression.cs

index ac275c68e810a9ec362b44ceced2d041b91eedbf..0855bc22de557702710153ee6e95bd56ef2a69c5 100644 (file)
@@ -236,12 +236,16 @@ namespace System.Linq.Expressions {
                                                return method;
                                }
 
-                               //
-                               // == and != allow reference types without operators defined.
-                               //
-                               if (!ltype.IsValueType && !rtype.IsValueType &&
-                                       (oper_name == "op_Equality" || oper_name == "op_Inequality"))
-                                       return null;
+                               if (oper_name == "op_Equality" || oper_name == "op_Inequality") {
+                                       //
+                                       // == and != allow reference types without operators defined.
+                                       //
+                                       if (!ltype.IsValueType && !rtype.IsValueType)
+                                               return null;
+
+                                       if (ltype == rtype && ultype == typeof (bool))
+                                               return null;
+                               }
 
                                throw new InvalidOperationException (
                                        String.Format ("Operation {0} not defined for {1} and {2}", oper_name != null ? oper_name.Substring (3) : "is", ltype, rtype));