Browse Source

Fix #2053: Assert and NRE in LocalFunctionDecompiler

pull/2055/head
Siegfried Pammer 5 years ago
parent
commit
74101ff0dc
  1. 6
      ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

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

@ -102,7 +102,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -102,7 +102,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (thisVar == null)
continue;
var compatibleArgument = FindCompatibleArgument(info, info.UseSites.SelectArray(u => u.Arguments[0]), ignoreStructure: true);
Debug.Assert(compatibleArgument != null);
if (compatibleArgument == null)
continue;
context.Step($"Replace 'this' with {compatibleArgument}", localFunction);
localFunction.AcceptVisitor(new DelegateConstruction.ReplaceDelegateTargetVisitor(compatibleArgument, thisVar));
DetermineCaptureAndDeclarationScope(info, -1, compatibleArgument);
@ -208,7 +209,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -208,7 +209,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (targetVariable == null)
continue;
var compatibleArgument = FindCompatibleArgument(info, arguments);
Debug.Assert(compatibleArgument != null);
if (compatibleArgument == null)
continue;
context.Step($"Replace '{targetVariable}' with '{compatibleArgument}'", info.Definition);
info.Definition.AcceptVisitor(new DelegateConstruction.ReplaceDelegateTargetVisitor(compatibleArgument, targetVariable));
}

Loading…
Cancel
Save