protected override Expression VisitConditionalExpression(ConditionalExpressionBindingParserNode node) { var condition = HandleErrors(node.ConditionExpression, n => TypeConversion.ImplicitConversion(Visit(n), typeof(bool), true)); var trueExpr = HandleErrors(node.TrueExpression, Visit); var falseExpr = HandleErrors(node.FalseExpression, Visit); ThrowOnErrors(); return(Expression.Condition(condition, trueExpr, falseExpr)); }
protected override Expression VisitConditionalExpression(ConditionalExpressionBindingParserNode node) { var condition = HandleErrors(node.ConditionExpression, n => TypeConversion.ImplicitConversion(Visit(n), typeof(bool), true)); var trueExpr = HandleErrors(node.TrueExpression, Visit); var falseExpr = HandleErrors(node.FalseExpression, Visit); ThrowOnErrors(); if (trueExpr.Type != falseExpr.Type) { trueExpr = TypeConversion.ImplicitConversion(trueExpr, falseExpr.Type, allowToString: true) ?? trueExpr; falseExpr = TypeConversion.ImplicitConversion(falseExpr, trueExpr.Type, allowToString: true) ?? falseExpr; } return(Expression.Condition(condition, trueExpr, falseExpr)); }