CanBeReachedByDownCastOrPromotion() public method

public CanBeReachedByDownCastOrPromotion ( IType expectedType, IType actualType ) : bool
expectedType IType
actualType IType
return bool
Example #1
0
        private int CalculateArgumentScore(IParameter param, IType parameterType, Node arg)
        {
            IType argumentType = GetExpressionTypeOrEntityType(arg);

            if (IsValidByRefArg(param, parameterType, argumentType, arg))
            {
                // boo does not like byref
                return(3);
            }
            else if (parameterType == argumentType)
            {
                // exact match
                return(6);
            }
            else if (parameterType.IsAssignableFrom(argumentType))
            {
                // upcast
                return(5);
            }
            else if (TypeSystemServices.CanBeReachedByDownCastOrPromotion(parameterType, argumentType))
            {
                // downcast
                return(4);
            }
            return(-1);
        }