diff --git a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs index 130349971..f90a57aff 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs @@ -228,6 +228,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms public TransformDisplayClassUsages(IInstructionWithVariableOperand targetLoad, BlockContainer captureScope, List orphanedVariableInits) { + this.currentFunction = captureScope.Ancestors.OfType().First(); this.targetLoad = targetLoad; this.captureScope = captureScope; this.orphanedVariableInits = orphanedVariableInits; @@ -241,17 +242,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms } } - protected internal override void VisitILFunction(ILFunction function) - { - var old = currentFunction; - currentFunction = function; - try { - base.VisitILFunction(function); - } finally { - currentFunction = old; - } - } - protected internal override void VisitStLoc(StLoc inst) { base.VisitStLoc(inst);