diff -r e701af23a095 -r 9851071b551a src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 18 18:57:52 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 18 19:02:48 2013 +0100 @@ -1532,21 +1532,23 @@ // If one arm has an integer subrange type (i.e., byte, // short, or char), and the other is an integer constant // that fits into the subrange, return the subrange type. - if (thenUnboxed.getTag().isStrictSubRangeOf(INT) && elseUnboxed.hasTag(INT) && - types.isAssignable(elseUnboxed, thenUnboxed)) + if (thenUnboxed.getTag().isStrictSubRangeOf(INT) && + elseUnboxed.hasTag(INT) && + types.isAssignable(elseUnboxed, thenUnboxed)) { return thenUnboxed.baseType(); - if (elseUnboxed.getTag().isStrictSubRangeOf(INT) && thenUnboxed.hasTag(INT) && - types.isAssignable(thenUnboxed, elseUnboxed)) + } + if (elseUnboxed.getTag().isStrictSubRangeOf(INT) && + thenUnboxed.hasTag(INT) && + types.isAssignable(thenUnboxed, elseUnboxed)) { return elseUnboxed.baseType(); - - for (TypeTag tag : TypeTag.values()) { - if (tag.ordinal() >= TypeTag.getTypeTagCount()) break; + } + + for (TypeTag tag : primitiveTags) { Type candidate = syms.typeOfTag[tag.ordinal()]; - if (candidate != null && - candidate.isPrimitive() && - types.isSubtype(thenUnboxed, candidate) && - types.isSubtype(elseUnboxed, candidate)) + if (types.isSubtype(thenUnboxed, candidate) && + types.isSubtype(elseUnboxed, candidate)) { return candidate; + } } } @@ -1575,6 +1577,17 @@ return types.lub(thentype.baseType(), elsetype.baseType()); } + final static TypeTag[] primitiveTags = new TypeTag[]{ + BYTE, + CHAR, + SHORT, + INT, + LONG, + FLOAT, + DOUBLE, + BOOLEAN, + }; + public void visitIf(JCIf tree) { attribExpr(tree.cond, env, syms.booleanType); attribStat(tree.thenpart, env);