From 51549134d6c18e491d31562da7db682e4b3e3eda Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 26 Mar 2018 23:15:39 +0200 Subject: [PATCH] Do never add casts to 'void'. --- ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs index 429f9fc89..694fb6de5 100644 --- a/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs +++ b/ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs @@ -198,8 +198,8 @@ namespace ICSharpCode.Decompiler.CSharp } return this; } - if (targetType.Kind == TypeKind.Unknown) { - return this; // don't attempt to insert cast to '?' + if (targetType.Kind == TypeKind.Unknown || targetType.Kind == TypeKind.Void) { + return this; // don't attempt to insert cast to '?' or 'void' as these are not valid. } if (Expression is UnaryOperatorExpression uoe && uoe.Operator == UnaryOperatorType.NullConditional && targetType.IsReferenceType == true) { // "(T)(x?).AccessChain" is invalid, but "((T)x)?.AccessChain" is valid and equivalent