public override Constant ConvertExplicitly(bool inCheckedContext, Type targetType)
{
if (targetType.IsPointer)
{
if (type == TypeManager.null_type || this is NullPointer)
{
return(new EmptyConstantCast(new NullPointer(loc), targetType));
}
return(null);
}
// Exlude internal compiler types
if (targetType == InternalType.AnonymousMethod)
{
return(null);
}
if (type != TypeManager.null_type && !Convert.ImplicitStandardConversionExists(this, targetType))
{
return(null);
}
if (TypeManager.IsReferenceType(targetType))
{
return(new NullLiteral(targetType, loc));
}
if (TypeManager.IsNullableType(targetType))
{
return(Nullable.LiftedNull.Create(targetType, loc));
}
return(null);
}