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

changeset 1869
5c548a8542b8
parent 1864
e42c27026290
child 1882
39ec5d8a691b
child 1886
79c3146e417b
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 12:42:47 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 17:45:56 2013 -0400
     1.3 @@ -3010,6 +3010,8 @@
     1.4                  !left.isErroneous() &&
     1.5                  !right.isErroneous()) {
     1.6              owntype = operator.type.getReturnType();
     1.7 +            // This will figure out when unboxing can happen and
     1.8 +            // choose the right comparison operator.
     1.9              int opc = chk.checkOperator(tree.lhs.pos(),
    1.10                                          (OperatorSymbol)operator,
    1.11                                          tree.getTag(),
    1.12 @@ -3037,9 +3039,11 @@
    1.13              }
    1.14  
    1.15              // Check that argument types of a reference ==, != are
    1.16 -            // castable to each other, (JLS???).
    1.17 +            // castable to each other, (JLS 15.21).  Note: unboxing
    1.18 +            // comparisons will not have an acmp* opc at this point.
    1.19              if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
    1.20 -                if (!types.isCastable(left, right, new Warner(tree.pos()))) {
    1.21 +                if (!types.isEqualityComparable(left, right,
    1.22 +                                                new Warner(tree.pos()))) {
    1.23                      log.error(tree.pos(), "incomparable.types", left, right);
    1.24                  }
    1.25              }

mercurial