From 24b2d17bb0efc4614ebee2515fd32299543aeaa0 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 26 Mar 2022 18:05:00 +0100 Subject: [PATCH] Fix #2582: Assertion when using named arguments in a constrained call (cherry picked from commit ced6ed445adf1b1165ae74f2723314fafd70dc4b) --- ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs index d2c5c400c..41e30e598 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/NamedArgumentTransform.cs @@ -98,7 +98,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms namedArgBlock.FinalInstruction = call; if (call.IsInstanceCall) { - IType thisVarType = call.Method.DeclaringType; + IType thisVarType = call.ConstrainedTo ?? call.Method.DeclaringType; if (CallInstruction.ExpectedTypeForThisPointer(thisVarType) == StackType.Ref) { thisVarType = new ByReferenceType(thisVarType);