@@ -1339,6 +1339,19 @@ class ExprAggregate extends TExprAggregate, Expr {
13391339 pred = indexedMember ( "getOrderBy" , i ) and result = this .getOrderBy ( i )
13401340 )
13411341 }
1342+
1343+ override Type getType ( ) {
1344+ exists ( PrimitiveType prim | prim = result |
1345+ kind .regexpMatch ( "(strict)?count|sum|min|max|rank" ) and
1346+ result .getName ( ) = "int"
1347+ or
1348+ kind .regexpMatch ( "(strict)?concat" ) and
1349+ result .getName ( ) = "string"
1350+ )
1351+ or
1352+ not kind = [ "count" , "strictcount" ] and
1353+ result = getExpr ( 0 ) .getType ( )
1354+ }
13421355}
13431356
13441357/** An aggregate expression, such as `count` or `sum`. */
@@ -1389,12 +1402,21 @@ class Aggregate extends TAggregate, Expr {
13891402
13901403 override string getAPrimaryQlClass ( ) { result = "Aggregate[" + kind + "]" }
13911404
1392- override PrimitiveType getType ( ) {
1393- kind .regexpMatch ( "(strict)?count|sum|min|max|rank" ) and
1394- result .getName ( ) = "int"
1405+ override Type getType ( ) {
1406+ exists ( PrimitiveType prim | prim = result |
1407+ kind .regexpMatch ( "(strict)?count|sum|min|max|rank" ) and
1408+ result .getName ( ) = "int"
1409+ or
1410+ kind .regexpMatch ( "(strict)?concat" ) and
1411+ result .getName ( ) = "string"
1412+ )
1413+ or
1414+ kind = [ "any" , "min" , "max" ] and
1415+ not exists ( getExpr ( _) ) and
1416+ result = getArgument ( 0 ) .getTypeExpr ( ) .getResolvedType ( )
13951417 or
1396- kind . regexpMatch ( "(strict)?concat" ) and
1397- result . getName ( ) = "string"
1418+ not kind = [ "count" , "strictcount" ] and
1419+ result = getExpr ( 0 ) . getType ( )
13981420 }
13991421
14001422 override AstNode getAChild ( string pred ) {
0 commit comments