Browse Source

Add test-case for #1462

pull/1476/head
Siegfried Pammer 6 years ago
parent
commit
983b7e5280
  1. 10
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstantsTests.cs
  2. 3
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

10
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ConstantsTests.cs

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal class ConstantsTests
{
@ -24,6 +26,12 @@ @@ -24,6 +26,12 @@
Test((v | 0x123) == 0);
}
public void Enum_Flag_Check(TaskCreationOptions v)
{
Test((v & TaskCreationOptions.AttachedToParent) != 0);
Test((v & TaskCreationOptions.AttachedToParent) == 0);
}
private void Test(bool expr)
{
}

3
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -773,8 +773,9 @@ namespace ICSharpCode.Decompiler.CSharp @@ -773,8 +773,9 @@ namespace ICSharpCode.Decompiler.CSharp
NullableType.GetUnderlyingType(right.Type).Kind == TypeKind.Enum &&
right.Expression is BinaryOperatorExpression binaryExpr &&
binaryExpr.Operator == BinaryOperatorType.BitwiseAnd)
{
return AdjustConstantExpressionToType(left, compilation.FindType(KnownTypeCode.Int32));
else
} else
return AdjustConstantExpressionToType(left, right.Type);
}

Loading…
Cancel
Save