private static MethodType widenOperators(MethodType mt) {
        if (mt.parameterCount()==2) {
            Class leftType = mt.parameterType(0);
            Class rightType = mt.parameterType(1);
            
            if (isIntCategory(leftType) && isIntCategory(rightType)) return IIV;
            if (isLongCategory(leftType) && isLongCategory(rightType)) return LLV;
            if (isBigDecCategory(leftType) && isBigDecCategory(rightType)) return GGV;
            if (isDoubleCategory(leftType) && isDoubleCategory(rightType)) return DDV;
            
            return OOV;
        } else if (mt.parameterCount()==1) {
            Class leftType = mt.parameterType(0);
            if (isIntCategory(leftType)) return IV;
            if (isLongCategory(leftType)) return LV;
            if (isBigDecCategory(leftType)) return GV;
            if (isDoubleCategory(leftType)) return DV;
        }
        return mt;
    }
private static MethodType widenOperators ( MethodType mt ) { if ( mt . parameterCount ( ) == 2 ) { Class leftType = mt . parameterType ( 0 ) ; Class rightType = mt . parameterType ( 1 ) ; if ( isIntCategory ( leftType ) && isIntCategory ( rightType ) ) return IIV ; if ( isLongCategory ( leftType ) && isLongCategory ( rightType ) ) return LLV ; if ( isBigDecCategory ( leftType ) && isBigDecCategory ( rightType ) ) return GGV ; if ( isDoubleCategory ( leftType ) && isDoubleCategory ( rightType ) ) return DDV ; return OOV ; } else if ( mt . parameterCount ( ) == 1 ) { Class leftType = mt . parameterType ( 0 ) ; if ( isIntCategory ( leftType ) ) return IV ; if ( isLongCategory ( leftType ) ) return LV ; if ( isBigDecCategory ( leftType ) ) return GV ; if ( isDoubleCategory ( leftType ) ) return DV ; } return mt ; }
Widens the operators. For math operations like a+b we generally
execute them using a conversion to certain types. If a for example
is an int and b a byte, we do the operation using integer math. This
method gives a simplified MethodType that contains the two operators
with this widening according to Groovy rules applied. That means both
parameters in the MethodType will have the same type.