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

Loading…
Cancel
Save