diff --git a/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs b/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs index e0c61ead1..de6883a4a 100644 --- a/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs +++ b/ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs @@ -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 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++) { diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs index 3487977ee..5d6794bf9 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs @@ -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 case ILFunction function: if (function.Kind == ILFunctionKind.ExpressionTree) { function.DelegateType = UnwrapExpressionTree(function.DelegateType); + function.Kind = ILFunctionKind.Delegate; } return (function, function.DelegateType); case LdLoc ldloc: