This is an automated email from the ASF dual-hosted git repository. emilles pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push: new eedf3a09a3 refactor checking eedf3a09a3 is described below commit eedf3a09a3846595c23ec80757f6f98e30cc3b09 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Wed Jun 26 16:18:37 2024 -0500 refactor checking --- .../transform/stc/StaticTypeCheckingVisitor.java | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 113490a4f3..49e9784380 100644 --- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -4764,32 +4764,37 @@ trying: for (ClassNode[] signature : signatures) { } } - // try to find a method for the operation - if (isShiftOperation(operationName) && isNumberCategory(leftRedirect) && (isIntCategory(rightRedirect) || isLongCategory(rightRedirect))) { + if (isShiftOperation(operationName) && isNumberCategory(leftRedirect) && isLongCategory(getUnwrapper(rightRedirect))) { return leftRedirect; } - // Divisions may produce different results depending on operand types - if (isNumberCategory(getWrapper(rightRedirect)) && (isNumberCategory(getWrapper(leftRedirect)) && (DIVIDE == op || DIVIDE_EQUAL == op))) { - if (isFloatingCategory(leftRedirect) || isFloatingCategory(rightRedirect)) { - if (!isPrimitiveType(leftRedirect) || !isPrimitiveType(rightRedirect)) { - return Double_TYPE; + if (isNumberCategory(getWrapper(leftRedirect)) && isNumberCategory(getWrapper(rightRedirect))) { + switch (op) { + case DIVIDE: + case DIVIDE_EQUAL: + // divisions may produce different results depending on operand types + if (isFloatingCategory(leftRedirect) || isFloatingCategory(rightRedirect)) { + if (!isPrimitiveType(leftRedirect) || !isPrimitiveType(rightRedirect)) { + return Double_TYPE; + } + return double_TYPE; } - return double_TYPE; - } - if (DIVIDE == op) { - return BigDecimal_TYPE; + if (DIVIDE == op) { + return BigDecimal_TYPE; + } + // falls through + case MOD: + case MOD_EQUAL: + case REMAINDER: + case REMAINDER_EQUAL: + return leftRedirect; } - return leftRedirect; - } else if (isOperationInGroup(op)) { - if (isNumberCategory(getWrapper(leftRedirect)) && isNumberCategory(getWrapper(rightRedirect))) { + + if (isOperationInGroup(op)) { return getGroupOperationResultType(leftRedirect, rightRedirect); } } - if (isNumberCategory(getWrapper(rightRedirect)) && isNumberCategory(getWrapper(leftRedirect)) && - (REMAINDER == op || REMAINDER_EQUAL == op || MOD == op || MOD_EQUAL == op)) { - return leftRedirect; - } + return null; }