From f49cc11c76147edfb830263e0558ecfcc43724ad Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 10 Aug 2019 10:52:49 +0200 Subject: [PATCH] Fix #1627: Allow constants as targets of dynamic calls. --- .../TestCases/Pretty/DynamicTests.cs | 5 +++++ ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs index c12a38c6d..2e299b63e 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/DynamicTests.cs @@ -410,6 +410,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } + private static bool ConstantTarget(dynamic a) + { + return true.Equals(a); + } + private static dynamic GetDynamic(int i) { return null; diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index 2a1b4ead4..575eb9d02 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -2891,7 +2891,6 @@ namespace ICSharpCode.Decompiler.CSharp { Debug.Assert(!argumentInfo.HasFlag(CSharpArgumentInfoFlags.NamedArgument)); Debug.Assert(!argumentInfo.HasFlag(CSharpArgumentInfoFlags.IsOut)); - Debug.Assert(!argumentInfo.HasFlag(CSharpArgumentInfoFlags.Constant)); if (argumentInfo.HasFlag(CSharpArgumentInfoFlags.IsStaticType) && IL.Transforms.TransformExpressionTrees.MatchGetTypeFromHandle(inst, out var callTargetType)) { return new TypeReferenceExpression(ConvertType(callTargetType))