@@ -1551,7 +1551,7 @@ class ExprAggregate extends TExprAggregate, Aggregate {
15511551
15521552 override Type getType ( ) {
15531553 exists ( PrimitiveType prim | prim = result |
1554- kind .regexpMatch ( "(strict)?count|sum|min|max|rank " ) and
1554+ kind .regexpMatch ( "(strict)?count" ) and
15551555 result .getName ( ) = "int"
15561556 or
15571557 kind .regexpMatch ( "(strict)?concat" ) and
@@ -1615,16 +1615,16 @@ class FullAggregate extends TFullAggregate, Aggregate {
16151615
16161616 override Type getType ( ) {
16171617 exists ( PrimitiveType prim | prim = result |
1618- kind . regexpMatch ( "(strict)?( count|sum|min|max|rank)" ) and
1618+ kind = [ " count" , "strictcount" ] and
16191619 result .getName ( ) = "int"
16201620 or
16211621 kind .regexpMatch ( "(strict)?concat" ) and
16221622 result .getName ( ) = "string"
16231623 )
16241624 or
1625- kind = [ "any" , "min" , "max" , "unique" ] and
1625+ kind = [ "any" , "min" , "max" , "unique" , "rank" , "sum" , "strictsum" ] and
16261626 not exists ( this .getExpr ( _) ) and
1627- result = this .getArgument ( 0 ) .getTypeExpr ( ) . getResolvedType ( )
1627+ result = this .getArgument ( 0 ) .getType ( )
16281628 or
16291629 not kind = [ "count" , "strictcount" ] and
16301630 result = this .getExpr ( 0 ) .getType ( )
@@ -1910,11 +1910,18 @@ private Expr exprOfPrimitiveAddType(PrimitiveType t) {
19101910 result .getType ( ) = getASubTypeOfAddPrimitive ( t )
19111911}
19121912
1913+ /**
1914+ * Gets a subtype of the given primitive type `prim`.
1915+ * This predicate does not consider float to be a supertype of int.
1916+ */
19131917private Type getASubTypeOfAddPrimitive ( PrimitiveType prim ) {
19141918 result = prim and
19151919 result .getName ( ) = [ "int" , "string" , "float" ]
19161920 or
1917- result .getASuperType ( ) = getASubTypeOfAddPrimitive ( prim )
1921+ exists ( Type superType | superType = getASubTypeOfAddPrimitive ( prim ) |
1922+ result .getASuperType ( ) = superType and
1923+ not ( result .getName ( ) = "int" and superType .getName ( ) = "float" )
1924+ )
19181925}
19191926
19201927/**
@@ -1957,15 +1964,18 @@ class MulDivModExpr extends TMulDivModExpr, BinOpExpr {
19571964 this .getLeftOperand ( ) .getType ( ) = result and
19581965 this .getRightOperand ( ) .getType ( ) = result
19591966 or
1960- // Both operands are subtypes of `int`
1961- result .getName ( ) = "int" and
1962- result = this .getLeftOperand ( ) . getType ( ) . getASuperType * ( ) and
1963- result = this .getRightOperand ( ) . getType ( ) . getASuperType * ( )
1967+ // Both operands are subtypes of `int`/`float`
1968+ result .getName ( ) = [ "int" , "float" ] and
1969+ exprOfPrimitiveAddType ( result ) = this .getLeftOperand ( ) and
1970+ exprOfPrimitiveAddType ( result ) = this .getRightOperand ( )
19641971 or
19651972 // Coercion from `int` to `float`
19661973 exists ( PrimitiveType i | result .getName ( ) = "float" and i .getName ( ) = "int" |
1967- this .getAnOperand ( ) .getType ( ) = result and
1968- this .getAnOperand ( ) .getType ( ) .getASuperType * ( ) = i
1974+ this .getLeftOperand ( ) = exprOfPrimitiveAddType ( result ) and
1975+ this .getRightOperand ( ) = exprOfPrimitiveAddType ( i )
1976+ or
1977+ this .getRightOperand ( ) = exprOfPrimitiveAddType ( result ) and
1978+ this .getLeftOperand ( ) = exprOfPrimitiveAddType ( i )
19691979 )
19701980 }
19711981
0 commit comments