This is from: // TODO: move to constant /// /// Attempts to do a compile-time folding of a constant cast. /// Expression TryReduce (EmitContext ec, Type target_type) { if (expr.Type == target_type) return expr; if (TypeManager.IsEnumType (target_type) && TypeManager.EnumToUnderlying (target_type) == expr.Type) return new EnumConstant ((Constant)expr, target_type); Index: expression.cs =================================================================== --- expression.cs (revision 49473) +++ expression.cs (working copy) @@ -1337,7 +1337,7 @@ if (expr.Type == target_type) return expr; - if (TypeManager.IsEnumType (target_type)) + if (TypeManager.IsEnumType (target_type) && TypeManager.EnumToUnderlying (target_type) == expr.Type) return new EnumConstant ((Constant)expr, target_type); Expression real_expr = expr;