diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs index 5db791b..6f9a467 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/TypeAnalysisTests.cs @@ -377,6 +377,23 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty { return (int)a == 0; } + + public static byte BoolToIntLocalUsedTwice(byte b, bool flag) + { + int num = (flag ? 1 : 0); + return (byte)(b + num >> num); + } + + public static int BoolToIntLocalAsLoopBound(object[] array, bool skipFirst) + { + int num = (skipFirst ? 1 : 0); + int num2 = array.Length - 1; + while (num2 >= num && array[num2] == null) + { + num2--; + } + return num2; + } } public enum UIntEnum : uint diff --git a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs index e6d44b0..ddea232 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs @@ -124,6 +124,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms { return false; // non-local code move might change semantics when there's split variables } + if (v.Type.IsKnownType(KnownTypeCode.Boolean) != target.Type.IsKnownType(KnownTypeCode.Boolean)) + { + return false; + } switch (v.Kind) { case VariableKind.Parameter: