bool __CanCastParam(DmdType fromParam, DmdType toParam) { if (fromParam.IsEquivalentTo(toParam)) { return(true); } var fromParamCorType = fromParam.__GetVerifierCorElementType(); if (__IsObjRef(fromParamCorType)) { return(fromParam.__CanCastTo(toParam)); } else if (__IsGenericVariable(fromParamCorType)) { if (!fromParam.__ConstrainedAsObjRef()) { return(false); } return(fromParam.__CanCastTo(toParam)); } else if (__IsPrimitiveType(fromParamCorType)) { var toParamCorType = toParam.__GetVerifierCorElementType(); if (__IsPrimitiveType(toParamCorType)) { if (toParamCorType == fromParamCorType) { return(true); } if ((toParamCorType != DDN.ElementType.Boolean) && (fromParamCorType != DDN.ElementType.Boolean) && (toParamCorType != DDN.ElementType.Char) && (fromParamCorType != DDN.ElementType.Char)) { if ((__Size(toParamCorType) == __Size(fromParamCorType)) && (__IsFloat(toParamCorType) == __IsFloat(fromParamCorType))) { return(true); } } } } return(false); }
static bool __CanCastTo(DmdType from, DmdType to) { if ((object)from == null) { throw new ArgumentNullException(nameof(from)); } if ((object)to == null) { throw new ArgumentNullException(nameof(to)); } bool res; var r = from.__CanCastToNoGC(to); if (r == __CastResult.MaybeCast) { res = from.__CanCastTo(to); } else { res = r == __CastResult.CanCast; } if (!res && to.IsNullable && !from.__IsTypeDesc()) { if (__IsNullableForType(to, from)) { res = true; } } return(res); }