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

Affected Versions
Versions known to exhibit this issue

No affected versions recorded.

Fixed Versions
Versions that include the fix
9.1.0-rc09.1.0-rc1025
Components
Server components related to this issue

No components specified.

Labels
Tags and classification

No labels assigned.