- if (targetType.IsPointer)
- return new EmptyConstantCast (NullPointer.Null, targetType);
-
- if (TypeManager.IsGenericParameter(targetType)) {
- GenericConstraints gc = null;
-
-#if GMCS_SOURCE
- gc = TypeManager.GetTypeParameterConstraints(targetType);
-#endif
- if (gc != null && gc.IsReferenceType)
- return new EmptyConstantCast (this, targetType);
+ //
+ // The 0 literal can be converted to an enum value
+ //
+ if (Value == 0 && type.IsEnum) {
+ Constant c = ConvertImplicitly (EnumSpec.GetUnderlyingType (type));
+ if (c == null)
+ return null;