private bool bindExplicitConversionFromNub()
{
Debug.Assert(_typeSrc != null);
Debug.Assert(_typeDest != null);
// If S and T are value types and there is a builtin conversion from S => T then there is an
// explicit conversion from S? => T that throws on null.
if (_typeDest.IsValType() && _binder.BindExplicitConversion(null, _typeSrc.StripNubs(), _exprTypeDest, _pDestinationTypeForLambdaErrorReporting, _flags | CONVERTTYPE.NOUDC))
{
if (_needsExprDest)
{
Expr valueSrc = _exprSrc;
// This is a holdover from the days when you could have nullable of nullable.
// Can we remove this loop?
while (valueSrc.Type is NullableType)
{
valueSrc = _binder.BindNubValue(valueSrc);
}
Debug.Assert(valueSrc.Type == _typeSrc.StripNubs());
if (!_binder.BindExplicitConversion(valueSrc, valueSrc.Type, _exprTypeDest, _pDestinationTypeForLambdaErrorReporting, _needsExprDest, out _exprDest, _flags | CONVERTTYPE.NOUDC))
{
VSFAIL("BindExplicitConversion failed unexpectedly");
return(false);
}
if (_exprDest is ExprUserDefinedConversion udc)
{
udc.Argument = _exprSrc;
}
}
return(true);
}
if ((_flags & CONVERTTYPE.NOUDC) == 0)
{
return(_binder.bindUserDefinedConversion(_exprSrc, _typeSrc, _typeDest, _needsExprDest, out _exprDest, false));
}
return(false);
}