Skip to content

Commit

Permalink
Correct the type of String + Object (#6941)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Jan 2, 2025
1 parent af87b07 commit 11a39c5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -952,13 +952,13 @@ public JavaExpression visit(BinaryExpr expr, Void aVoid) {
TypeMirror rightType = rightJe.getType();
TypeMirror type;
// isSubtype() first does the cheaper test isSameType(), so no need to do it here.
if (types.isSubtype(leftType, rightType)) {
if (expr.getOperator() == BinaryExpr.Operator.PLUS
&& (TypesUtils.isString(leftType) || TypesUtils.isString(rightType))) {
type = stringTypeMirror;
} else if (types.isSubtype(leftType, rightType)) {
type = rightType;
} else if (types.isSubtype(rightType, leftType)) {
type = leftType;
} else if (expr.getOperator() == BinaryExpr.Operator.PLUS
&& (TypesUtils.isString(leftType) || TypesUtils.isString(rightType))) {
type = stringTypeMirror;
} else {
throw new ParseRuntimeException(
constructJavaExpressionParseError(
Expand Down

0 comments on commit 11a39c5

Please sign in to comment.