langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 18662 1cac45e71eb9
parent 18657 2bd14bebdf57
child 18730 95354d510139
child 18899 2557b27d1f1c
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 12:42:47 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 17:45:56 2013 -0400
@@ -3010,6 +3010,8 @@
                 !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(),
@@ -3037,9 +3039,11 @@
             }
 
             // Check that argument types of a reference ==, != are
-            // castable to each other, (JLS???).
+            // 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.isCastable(left, right, new Warner(tree.pos()))) {
+                if (!types.isEqualityComparable(left, right,
+                                                new Warner(tree.pos()))) {
                     log.error(tree.pos(), "incomparable.types", left, right);
                 }
             }