Browse Source

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

pull/1790/head
Siegfried Pammer 6 years ago
parent
commit
9bb2ea872c
  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

@ -322,7 +322,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -322,7 +322,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
parameter = null;
if (!IsDisplayClassFieldAccess(inst.Target, out var displayClassVar, out displayClass, out field))
return false;
if (!(inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && v.Function == currentFunction))
if (!(inst.Value.MatchLdLoc(out var v) && v.Kind == VariableKind.Parameter && v.Function == currentFunction && v.Type.Equals(field.Type)))
return false;
if (displayClass.Variables.ContainsKey((IField)field.MemberDefinition))
return false;

Loading…
Cancel
Save