diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs index 2409c65a91..7f80f24771 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs @@ -385,5 +385,11 @@ public static Func CapturedTypeParameter2(TN return captured.FirstOrDefault(); }; } + + public static Func Issue1773(short data) + { + int integerData = data; + return () => integerData; + } } } diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs index 7289797078..3338022779 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs @@ -314,7 +314,7 @@ protected internal override void VisitStObj(StObj inst) } else { // This is an uninitialized variable: ILInstruction value; - if (inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && currentFunction == v.Function) { + if (inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && currentFunction == v.Function && v.Type.Equals(fieldType)) { // Special case for parameters: remove copies of parameter values. instructionsToRemove.Add(inst); value = inst.Value;