SERVER-135982ClosedFixed
Add type inference visitors for aggregation expressions
Signature: This should dispatch via a visitor similar to matcher::narrowType. So that we can call getOutputType(ExpressionConstant, ...) or getOutputType(ExpressionFieldPath, ...) and get the output type of the expression. And narrowType on ExpressionCompare etc. Make $expr call narrowType when the output of the expression is boolean, to wire things together. We should check the expression is boolean to match cases $expr: {$eq: [...]} but not $expr: {$add: [...]}} which is valid, but