Skip to content

Commit 29861d7

Browse files
Fix #1647: Add a cast to enum constants where the enum type is not known.
1 parent 356d7a1 commit 29861d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ public Expression ConvertConstantValue(IType expectedType, IType type, object co
11341134
expr = new PrimitiveExpression(constantValue, format);
11351135
if (AddResolveResultAnnotations && literalType != null)
11361136
expr.AddAnnotation(new ConstantResolveResult(literalType, constantValue));
1137-
if (integerTypeMismatch && !type.Equals(expectedType))
1137+
if (integerTypeMismatch && !type.Equals(expectedType) || underlyingType.Kind == TypeKind.Unknown)
11381138
{
11391139
expr = new CastExpression(ConvertType(type), expr);
11401140
}

0 commit comments

Comments
 (0)