Browse Source

#1773: Remove copies of parameter values only if the types match exactly.

v5.0.2
Siegfried Pammer 6 years ago
parent
commit
77385d4904
  1. 6
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs
  2. 2
      ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs

6
ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs

@ -385,5 +385,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -385,5 +385,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return captured.FirstOrDefault();
};
}
public static Func<int> Issue1773(short data)
{
int integerData = data;
return () => integerData;
}
}
}

2
ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs

@ -314,7 +314,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -314,7 +314,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} 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;

Loading…
Cancel
Save