Skip to content

Commit fc27944

Browse files
author
emmanue1
committed
Fix bad operand types for binary operator '|'
1 parent c00e0ac commit fc27944

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ByteCodeParser.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,16 +1825,22 @@ private Expression newIntegerOrBooleanBinaryOperatorExpression(int lineNumber, E
18251825
leftVariable.typeOnRight(typeBounds, type = TYPE_BOOLEAN);
18261826
}
18271827
}
1828-
} else {
1829-
if (rightExpression.isLocalVariableReferenceExpression()) {
1830-
if (leftExpression.getType() == TYPE_BOOLEAN) {
1831-
AbstractLocalVariable rightVariable = ((ClassFileLocalVariableReferenceExpression)rightExpression).getLocalVariable();
1828+
} else if (rightExpression.isLocalVariableReferenceExpression()) {
1829+
if (leftExpression.getType() == TYPE_BOOLEAN) {
1830+
AbstractLocalVariable rightVariable = ((ClassFileLocalVariableReferenceExpression)rightExpression).getLocalVariable();
1831+
rightVariable.typeOnRight(typeBounds, type = TYPE_BOOLEAN);
1832+
}
1833+
}
18321834

1833-
rightVariable.typeOnRight(typeBounds, type = TYPE_BOOLEAN);
1834-
}
1835+
if (type == TYPE_INT) {
1836+
if ((leftExpression.getType() == TYPE_BOOLEAN) || (rightExpression.getType() == TYPE_BOOLEAN)) {
1837+
type = TYPE_BOOLEAN;
18351838
}
18361839
}
18371840

1841+
bindParameterTypesWithArgumentTypes(leftExpression.getType(), rightExpression);
1842+
bindParameterTypesWithArgumentTypes(rightExpression.getType(), leftExpression);
1843+
18381844
return new BinaryOperatorExpression(lineNumber, type, leftExpression, operator, rightExpression, priority);
18391845
}
18401846

@@ -1858,12 +1864,10 @@ private Expression newIntegerOrBooleanComparisonOperatorExpression(int lineNumbe
18581864
leftVariable.typeOnRight(typeBounds, TYPE_BOOLEAN);
18591865
}
18601866
}
1861-
} else {
1862-
if (rightExpression.isLocalVariableReferenceExpression()) {
1863-
if (leftExpression.getType() == TYPE_BOOLEAN) {
1864-
AbstractLocalVariable rightVariable = ((ClassFileLocalVariableReferenceExpression)rightExpression).getLocalVariable();
1865-
rightVariable.typeOnRight(typeBounds, TYPE_BOOLEAN);
1866-
}
1867+
} else if (rightExpression.isLocalVariableReferenceExpression()) {
1868+
if (leftExpression.getType() == TYPE_BOOLEAN) {
1869+
AbstractLocalVariable rightVariable = ((ClassFileLocalVariableReferenceExpression)rightExpression).getLocalVariable();
1870+
rightVariable.typeOnRight(typeBounds, TYPE_BOOLEAN);
18671871
}
18681872
}
18691873

@@ -1888,6 +1892,9 @@ private Expression newIntegerComparisonOperatorExpression(int lineNumber, Expres
18881892
rightVariable.typeOnLeft(typeBounds, MAYBE_BYTE_TYPE);
18891893
}
18901894

1895+
bindParameterTypesWithArgumentTypes(leftExpression.getType(), rightExpression);
1896+
bindParameterTypesWithArgumentTypes(rightExpression.getType(), leftExpression);
1897+
18911898
return new BinaryOperatorExpression(lineNumber, TYPE_BOOLEAN, leftExpression, operator, rightExpression, priority);
18921899
}
18931900

0 commit comments

Comments
 (0)