Skip to content

Commit 428079d

Browse files
committed
Fix #3423
1 parent a264217 commit 428079d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

ICSharpCode.Decompiler.Tests/TestCases/Pretty/EnumTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
1+
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
44
// software and associated documentation files (the "Software"), to deal in the Software
@@ -135,5 +135,13 @@ public object PreservingTypeWhenBoxedTwoEnum()
135135
{
136136
return AttributeTargets.Class | AttributeTargets.Delegate;
137137
}
138+
139+
public void EnumInNotZeroCheck(SimpleEnum value)
140+
{
141+
if (value != SimpleEnum.Item1)
142+
{
143+
Console.WriteLine();
144+
}
145+
}
138146
}
139147
}

ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2014 Daniel Grunwald
1+
// Copyright (c) 2014 Daniel Grunwald
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
44
// software and associated documentation files (the "Software"), to deal in the Software
@@ -733,9 +733,9 @@ public TranslatedExpression ConvertToBoolean(ExpressionBuilder expressionBuilder
733733
}
734734
else
735735
{
736-
var zero = new PrimitiveExpression(0)
737-
.WithoutILInstruction()
738-
.WithRR(new ConstantResolveResult(expressionBuilder.compilation.FindType(KnownTypeCode.Int32), 0));
736+
TranslatedExpression zero = expressionBuilder
737+
.ConvertConstantValue(new ConstantResolveResult(Type, 0), allowImplicitConversion: false)
738+
.WithoutILInstruction();
739739
var op = negate ? BinaryOperatorType.Equality : BinaryOperatorType.InEquality;
740740
return new BinaryOperatorExpression(Expression, op, zero.Expression)
741741
.WithoutILInstruction()

0 commit comments

Comments
 (0)