IsSystemObject() public method

checks if the passed type will be equivalente to System.Object in runtime (accounting for the presence of duck typing).
public IsSystemObject ( IType type ) : bool
type IType
return bool
Exemplo n.º 1
0
        private int CalculateArgumentScore(IType parameterType, IType argumentType)
        {
            if (parameterType == argumentType || (TypeSystemServices.IsSystemObject(argumentType) && TypeSystemServices.IsSystemObject(parameterType)))
            {
                return(parameterType is ICallableType ? CallableExactMatchScore : ExactMatchScore);
            }

            if (TypeCompatibilityRules.IsAssignableFrom(parameterType, argumentType))
            {
                var callableType = parameterType as ICallableType;
                var callableArg  = argumentType as ICallableType;
                if (callableType != null && callableArg != null)
                {
                    return(CalculateCallableScore(callableType, callableArg));
                }
                return(UpCastScore);
            }

            if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
            {
                return(ImplicitConversionScore);
            }

            if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
            {
                return(IsWideningPromotion(parameterType, argumentType) ? WideningPromotion : NarrowingPromotion);
            }

            if (MyDowncastPermissions().CanBeReachedByDowncast(parameterType, argumentType))
            {
                return(DowncastScore);
            }

            return(-1);
        }
Exemplo n.º 2
0
        private int CalculateArgumentScore(IParameter param, IType parameterType, Node arg)
        {
            IType argumentType = GetExpressionTypeOrEntityType(arg);

            if (param.IsByRef)
            {
                if (IsValidByRefArg(param, parameterType, argumentType, arg))
                {
                    return(ExactMatchScore);
                }
                return(-1);
            }
            else if (parameterType == argumentType ||
                     (TypeSystemServices.IsSystemObject(argumentType) &&
                      TypeSystemServices.IsSystemObject(parameterType)))
            {
                return(parameterType is ICallableType
                                        ? CallableExactMatchScore
                                        : ExactMatchScore);
            }
            else if (parameterType.IsAssignableFrom(argumentType))
            {
                ICallableType callableType = parameterType as ICallableType;
                ICallableType callableArg  = argumentType as ICallableType;
                if (callableType != null && callableArg != null)
                {
                    return(CalculateCallableScore(callableType, callableArg));
                }
                return(UpCastScore);
            }
            else if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
            {
                return(ImplicitConversionScore);
            }
            else if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
            {
                if (IsWideningPromotion(parameterType, argumentType))
                {
                    return(WideningPromotion);
                }
                return(NarrowingPromotion);
            }
            else if (TypeSystemServices.CanBeReachedByDowncast(parameterType, argumentType))
            {
                return(DowncastScore);
            }
            return(-1);
        }