- 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;
- }
-
- public override Constant ConvertImplicitly (Type targetType)
- {
- //
- // Null literal is of object type
- //
- if (targetType == TypeManager.object_type)
- return this;
-
- return ConvertExplicitly (false, targetType);
- }
-
- public override object GetValue ()
- {
- return null;
- }
-
- public override Constant Increment ()
- {
- throw new NotSupportedException ();
- }
-
- public override bool IsDefaultValue {
- get { return true; }
- }
-