Browse Source

Fix assertions in TransformExpressionTrees.

pull/1586/head
Siegfried Pammer 6 years ago
parent
commit
b42d4963e7
  1. 2
      ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs
  2. 2
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

2
ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs

@ -144,6 +144,7 @@ namespace ICSharpCode.Decompiler.IL @@ -144,6 +144,7 @@ namespace ICSharpCode.Decompiler.IL
case ILFunctionKind.TopLevelFunction:
Debug.Assert(Parent == null);
Debug.Assert(DelegateType == null);
Debug.Assert(Method != null);
break;
case ILFunctionKind.Delegate:
Debug.Assert(Parent != null && !(Parent is Block));
@ -158,6 +159,7 @@ namespace ICSharpCode.Decompiler.IL @@ -158,6 +159,7 @@ namespace ICSharpCode.Decompiler.IL
case ILFunctionKind.LocalFunction:
Debug.Assert(Parent is Block);
Debug.Assert(DelegateType == null);
Debug.Assert(Method != null);
break;
}
for (int i = 0; i < Variables.Count; i++) {

2
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -156,6 +156,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -156,6 +156,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var returnType = functionType.GetDelegateInvokeMethod()?.ReturnType;
var function = new ILFunction(returnType, parameterList, context.Function.GenericContext, container);
function.DelegateType = functionType;
function.Kind = IsExpressionTree(functionType) ? ILFunctionKind.ExpressionTree : ILFunctionKind.Delegate;
function.Variables.AddRange(parameterVariablesList);
function.AddILRange(instruction);
lambdaStack.Push(function);
@ -343,6 +344,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -343,6 +344,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
case ILFunction function:
if (function.Kind == ILFunctionKind.ExpressionTree) {
function.DelegateType = UnwrapExpressionTree(function.DelegateType);
function.Kind = ILFunctionKind.Delegate;
}
return (function, function.DelegateType);
case LdLoc ldloc:

Loading…
Cancel
Save