Skip to content

Commit 1f2b855

Browse files
author
rstam
committed
Merged in implementation of CSHARP-458 with one additional check to make sure cast doesn't fail.
1 parent 27a7d41 commit 1f2b855

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Driver/Linq/Expressions/ExpressionNormalizer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,16 @@ protected override Expression VisitBinary(BinaryExpression node)
8282
}
8383
}
8484

85-
//VB creates coalescing operations when dealing with nullable value comparisons, so we try and make this look like C#\
85+
// VB creates coalescing operations when dealing with nullable value comparisons, so we try and make this look like C#
8686
if (node.NodeType == ExpressionType.Coalesce)
8787
{
8888
var right = node.Right as ConstantExpression;
89-
if (node.Left.NodeType == ExpressionType.Equal
90-
&& node.Left.Type.IsGenericType
91-
&& node.Left.Type.GetGenericTypeDefinition() == typeof(Nullable<>)
92-
&& right != null
93-
&& (bool)right.Value == false)
89+
if (node.Left.NodeType == ExpressionType.Equal &&
90+
node.Left.Type.IsGenericType &&
91+
node.Left.Type.GetGenericTypeDefinition() == typeof(Nullable<>) &&
92+
right != null &&
93+
right.Type == typeof(bool) &&
94+
(bool)right.Value == false)
9495
{
9596
node = (BinaryExpression)node.Left;
9697
return Expression.MakeBinary(

0 commit comments

Comments
 (0)