src/share/classes/com/sun/tools/javac/comp/Check.java

changeset 1826
9851071b551a
parent 1824
455be95bd1b5
child 1842
6d3b33aea370
child 1843
be62183f938a
equal deleted inserted replaced
1825:e701af23a095 1826:9851071b551a
542 if (req.hasTag(NONE)) 542 if (req.hasTag(NONE))
543 return found; 543 return found;
544 if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) { 544 if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
545 return found; 545 return found;
546 } else { 546 } else {
547 if (found.getTag().isSubRangeOf(DOUBLE) && req.getTag().isSubRangeOf(DOUBLE)) { 547 if (found.isNumeric() && req.isNumeric()) {
548 checkContext.report(pos, diags.fragment("possible.loss.of.precision", found, req)); 548 checkContext.report(pos, diags.fragment("possible.loss.of.precision", found, req));
549 return types.createErrorType(found); 549 return types.createErrorType(found);
550 } 550 }
551 checkContext.report(pos, diags.fragment("inconvertible.types", found, req)); 551 checkContext.report(pos, diags.fragment("inconvertible.types", found, req));
552 return types.createErrorType(found); 552 return types.createErrorType(found);
752 /** Check that type is a null or reference type. 752 /** Check that type is a null or reference type.
753 * @param pos Position to be used for error reporting. 753 * @param pos Position to be used for error reporting.
754 * @param t The type to be checked. 754 * @param t The type to be checked.
755 */ 755 */
756 Type checkNullOrRefType(DiagnosticPosition pos, Type t) { 756 Type checkNullOrRefType(DiagnosticPosition pos, Type t) {
757 if (t.isNullOrReference()) 757 if (t.isReference() || t.hasTag(BOT))
758 return t; 758 return t;
759 else 759 else
760 return typeTagError(pos, 760 return typeTagError(pos,
761 diags.fragment("type.req.ref"), 761 diags.fragment("type.req.ref"),
762 t); 762 t);
3226 * @param operand The right hand operand for the expression 3226 * @param operand The right hand operand for the expression
3227 */ 3227 */
3228 void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) { 3228 void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) {
3229 if (operand.constValue() != null 3229 if (operand.constValue() != null
3230 && lint.isEnabled(LintCategory.DIVZERO) 3230 && lint.isEnabled(LintCategory.DIVZERO)
3231 && (operand.getTag().isSubRangeOf(LONG)) 3231 && operand.getTag().isSubRangeOf(LONG)
3232 && ((Number) (operand.constValue())).longValue() == 0) { 3232 && ((Number) (operand.constValue())).longValue() == 0) {
3233 int opc = ((OperatorSymbol)operator).opcode; 3233 int opc = ((OperatorSymbol)operator).opcode;
3234 if (opc == ByteCodes.idiv || opc == ByteCodes.imod 3234 if (opc == ByteCodes.idiv || opc == ByteCodes.imod
3235 || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) { 3235 || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) {
3236 log.warning(LintCategory.DIVZERO, pos, "div.zero"); 3236 log.warning(LintCategory.DIVZERO, pos, "div.zero");

mercurial