src/share/classes/com/sun/tools/javac/comp/Attr.java
Print this page
*** 2989,2998 ****
--- 2989,3000 ----
Type owntype = types.createErrorType(tree.type);
if (operator.kind == MTH &&
!left.isErroneous() &&
!right.isErroneous()) {
owntype = operator.type.getReturnType();
+ // This will figure out when unboxing can happen and
+ // choose the right comparison operator.
int opc = chk.checkOperator(tree.lhs.pos(),
(OperatorSymbol)operator,
tree.getTag(),
left,
right);
*** 3016,3028 ****
}
}
}
// Check that argument types of a reference ==, != are
! // castable to each other, (JLS???).
if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
! if (!types.isCastable(left, right, new Warner(tree.pos()))) {
log.error(tree.pos(), "incomparable.types", left, right);
}
}
chk.checkDivZero(tree.rhs.pos(), operator, right);
--- 3018,3032 ----
}
}
}
// Check that argument types of a reference ==, != are
! // castable to each other, (JLS 15.21). Note: unboxing
! // comparisons will not have an acmp* opc at this point.
if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
! if (!types.isEqualityComparable(left, right,
! new Warner(tree.pos()))) {
log.error(tree.pos(), "incomparable.types", left, right);
}
}
chk.checkDivZero(tree.rhs.pos(), operator, right);