Skip to content

Commit 11a39c5

Browse files
authored
Correct the type of String + Object (#6941)
1 parent af87b07 commit 11a39c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

framework/src/main/java/org/checkerframework/framework/util/JavaExpressionParseUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,13 +952,13 @@ public JavaExpression visit(BinaryExpr expr, Void aVoid) {
952952
TypeMirror rightType = rightJe.getType();
953953
TypeMirror type;
954954
// isSubtype() first does the cheaper test isSameType(), so no need to do it here.
955-
if (types.isSubtype(leftType, rightType)) {
955+
if (expr.getOperator() == BinaryExpr.Operator.PLUS
956+
&& (TypesUtils.isString(leftType) || TypesUtils.isString(rightType))) {
957+
type = stringTypeMirror;
958+
} else if (types.isSubtype(leftType, rightType)) {
956959
type = rightType;
957960
} else if (types.isSubtype(rightType, leftType)) {
958961
type = leftType;
959-
} else if (expr.getOperator() == BinaryExpr.Operator.PLUS
960-
&& (TypesUtils.isString(leftType) || TypesUtils.isString(rightType))) {
961-
type = stringTypeMirror;
962962
} else {
963963
throw new ParseRuntimeException(
964964
constructJavaExpressionParseError(

0 commit comments

Comments
 (0)