diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs index 8a959d7a5..3028313e2 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs @@ -57,8 +57,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow KeyValuePair defaultSection; if (analysisSuccess && UseCSharpSwitch(analysis, out defaultSection)) { // complex multi-block switch that can be combined into a single SwitchInstruction - - var sw = new SwitchInstruction(new LdLoc(analysis.SwitchVariable)); + ILInstruction switchValue = new LdLoc(analysis.SwitchVariable); + if (switchValue.ResultType == StackType.Unknown) { + // switchValue must have a result type of either I4 or I8 + switchValue = new Conv(switchValue, PrimitiveType.I8, false, TypeSystem.Sign.Signed); + } + var sw = new SwitchInstruction(switchValue); foreach (var section in analysis.Sections) { sw.Sections.Add(new SwitchSection { Labels = section.Key,