System.Linq.Expressions.Expression.ValidateCoalesceArgTypes C# (CSharp) Method

ValidateCoalesceArgTypes() private static method

private static ValidateCoalesceArgTypes ( Type left, Type right ) : Type
left Type
right Type
return Type
        private static Type ValidateCoalesceArgTypes(Type left, Type right)
        {
            Type leftStripped = left.GetNonNullableType();
            if (left.GetTypeInfo().IsValueType && !left.IsNullableType())
            {
                throw Error.CoalesceUsedOnNonNullType();
            }
            else if (left.IsNullableType() && right.IsImplicitlyConvertibleTo(leftStripped))
            {
                return leftStripped;
            }
            else if (right.IsImplicitlyConvertibleTo(left))
            {
                return left;
            }
            else if (leftStripped.IsImplicitlyConvertibleTo(right))
            {
                return right;
            }
            else
            {
                throw Error.ArgumentTypesMustMatch();
            }
        }
Expression