Browse Source

Fix #1614: Don't suppress all casts to unknown types

Just those where we don't even know the name of the unknown type.
pull/1686/head
Daniel Grunwald 6 years ago
parent
commit
8c4066d471
  1. 8
      ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

8
ICSharpCode.Decompiler/CSharp/TranslatedExpression.cs

@ -223,8 +223,14 @@ namespace ICSharpCode.Decompiler.CSharp @@ -223,8 +223,14 @@ namespace ICSharpCode.Decompiler.CSharp
}
return this;
}
if (targetType.Kind == TypeKind.Unknown || targetType.Kind == TypeKind.Void || targetType.Kind == TypeKind.None) {
if (targetType.Kind == TypeKind.Void || targetType.Kind == TypeKind.None) {
return this; // don't attempt to insert cast to '?' or 'void' as these are not valid.
} else if (targetType.Kind == TypeKind.Unknown) {
// don't attempt cast to '?', or casts between an unknown type and a known type with same name
if (targetType.Name == "?" || targetType.ReflectionName == type.ReflectionName) {
return this;
}
// However we still want explicit casts to types that are merely unresolved
}
var convAnnotation = this.Expression.Annotation<ImplicitConversionAnnotation>();
if (convAnnotation != null) {

Loading…
Cancel
Save