Browse Source

Fix #867: Async delegate tries to access variables with "this." although they are local.

pull/876/merge
Siegfried Pammer 8 years ago
parent
commit
7bbbf39e3a
  1. 12
      ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs

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

@ -162,6 +162,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// <summary> /// <summary>
/// Replaces loads of 'this' with the target expression. /// Replaces loads of 'this' with the target expression.
/// Async delegates use: ldobj(ldloca this).
/// </summary> /// </summary>
class ReplaceDelegateTargetVisitor : ILVisitor class ReplaceDelegateTargetVisitor : ILVisitor
{ {
@ -183,12 +184,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
protected internal override void VisitLdLoc(LdLoc inst) protected internal override void VisitLdLoc(LdLoc inst)
{ {
if (inst.MatchLdLoc(thisVariable)) { if (inst.Variable == thisVariable) {
inst.ReplaceWith(target.Clone()); inst.ReplaceWith(target.Clone());
return; return;
} }
base.VisitLdLoc(inst); base.VisitLdLoc(inst);
} }
protected internal override void VisitLdObj(LdObj inst)
{
if (inst.Target.MatchLdLoca(thisVariable)) {
inst.ReplaceWith(target.Clone());
return;
}
base.VisitLdObj(inst);
}
} }
/// <summary> /// <summary>

Loading…
Cancel
Save