Browse Source

Do never add casts to 'void'.

pull/1108/head
Siegfried Pammer 7 years ago
parent
commit
51549134d6
  1. 4
      ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

4
ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

@ -198,8 +198,8 @@ namespace ICSharpCode.Decompiler.CSharp @@ -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

Loading…
Cancel
Save