Browse Source

Fix #1879: Do not remove variables that look like display class variables, but are used in other patterns as well.

pull/1968/head
Siegfried Pammer 5 years ago
parent
commit
69ac54fbb6
  1. 5
      ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs

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

@ -97,6 +97,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -97,6 +97,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
private bool CanRemoveAllReferencesTo(ILTransformContext context, ILVariable v)
{
foreach (var use in v.LoadInstructions) {
// we only accept stloc, stobj/ldobj and ld(s)flda instructions,
// as these are required by all patterns this transform understands.
if (!(use.Parent is StLoc || use.Parent is LdFlda || use.Parent is LdsFlda || use.Parent is StObj || use.Parent is LdObj)) {
return false;
}
if (use.Parent.MatchStLoc(out var targetVar) && !IsClosure(context, targetVar, out _, out _)) {
return false;
}

Loading…
Cancel
Save