in src/main/java/net/hydromatic/linq4j/expressions/Expressions.java [1496:1519]
public static TernaryExpression makeTernary(ExpressionType ternaryType,
Expression e0, Expression e1, Expression e2) {
final Type type;
switch (ternaryType) {
case Conditional:
if (e1 instanceof ConstantUntypedNull) {
type = box(e2.getType());
if (e1.getType() != type) {
e1 = constant(null, type);
}
} else if (e2 instanceof ConstantUntypedNull) {
type = box(e1.getType());
if (e2.getType() != type) {
e2 = constant(null, type);
}
} else {
type = Types.gcd(e1.getType(), e2.getType());
}
break;
default:
type = e1.getType();
}
return new TernaryExpression(ternaryType, type, e0, e1, e2);
}