Browse Source

Fix #939: Enum values in bitwise operations are not properly decompiled

pull/940/merge
Siegfried Pammer 8 years ago
parent
commit
14448071a3
  1. 6
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

6
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -694,6 +694,12 @@ namespace ICSharpCode.Decompiler.CSharp @@ -694,6 +694,12 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
if ((op == BinaryOperatorType.BitwiseAnd || op == BinaryOperatorType.BitwiseOr || op == BinaryOperatorType.ExclusiveOr)
&& (left.Type.Kind == TypeKind.Enum || right.Type.Kind == TypeKind.Enum)) {
left = AdjustConstantExpressionToType(left, right.Type);
right = AdjustConstantExpressionToType(right, left.Type);
}
var rr = resolverWithOverflowCheck.ResolveBinaryOperator(op, left.ResolveResult, right.ResolveResult);
if (rr.IsError || NullableType.GetUnderlyingType(rr.Type).GetStackType() != inst.UnderlyingResultType
|| !IsCompatibleWithSign(left.Type, inst.Sign) || !IsCompatibleWithSign(right.Type, inst.Sign))

Loading…
Cancel
Save