Browse Source

Fix bug in DelegateConstruction: ILVariables were added to the wrong ILFunction

pull/892/merge
Siegfried Pammer 8 years ago
parent
commit
46fdfd4b41
  1. 6
      ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs

6
ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
foreach (var target in targetsToReplace.OrderByDescending(t => ((ILInstruction)t).ILRange.Start)) { foreach (var target in targetsToReplace.OrderByDescending(t => ((ILInstruction)t).ILRange.Start)) {
function.AcceptVisitor(new TransformDisplayClassUsages(target, target.Variable.CaptureScope, orphanedVariableInits)); function.AcceptVisitor(new TransformDisplayClassUsages(function, target, target.Variable.CaptureScope, orphanedVariableInits));
} }
foreach (var store in orphanedVariableInits) { foreach (var store in orphanedVariableInits) {
if (store.Parent is Block containingBlock) if (store.Parent is Block containingBlock)
@ -226,9 +226,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public ILInstruction value; public ILInstruction value;
} }
public TransformDisplayClassUsages(IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List<ILInstruction> orphanedVariableInits) public TransformDisplayClassUsages(ILFunction function, IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List<ILInstruction> orphanedVariableInits)
{ {
this.currentFunction = captureScope.Ancestors.OfType<ILFunction>().First(); this.currentFunction = function;
this.targetLoad = targetLoad; this.targetLoad = targetLoad;
this.captureScope = captureScope; this.captureScope = captureScope;
this.orphanedVariableInits = orphanedVariableInits; this.orphanedVariableInits = orphanedVariableInits;

Loading…
Cancel
Save