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

Print this page




3003                 if (ctype != null) {
3004                     owntype = cfolder.coerce(ctype, owntype);
3005 
3006                     // Remove constant types from arguments to
3007                     // conserve space. The parser will fold concatenations
3008                     // of string literals; the code here also
3009                     // gets rid of intermediate results when some of the
3010                     // operands are constant identifiers.
3011                     if (tree.lhs.type.tsym == syms.stringType.tsym) {
3012                         tree.lhs.type = syms.stringType;
3013                     }
3014                     if (tree.rhs.type.tsym == syms.stringType.tsym) {
3015                         tree.rhs.type = syms.stringType;
3016                     }
3017                 }
3018             }
3019 
3020             // Check that argument types of a reference ==, != are
3021             // castable to each other, (JLS???).
3022             if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
3023                 if (!types.isCastable(left, right, new Warner(tree.pos()))) {

3024                     log.error(tree.pos(), "incomparable.types", left, right);
3025                 }
3026             }
3027 
3028             chk.checkDivZero(tree.rhs.pos(), operator, right);
3029         }
3030         result = check(tree, owntype, VAL, resultInfo);
3031     }
3032 
3033     public void visitTypeCast(final JCTypeCast tree) {
3034         Type clazztype = attribType(tree.clazz, env);
3035         chk.validate(tree.clazz, env, false);
3036         //a fresh environment is required for 292 inference to work properly ---
3037         //see Infer.instantiatePolymorphicSignatureInstance()
3038         Env<AttrContext> localEnv = env.dup(tree);
3039         //should we propagate the target type?
3040         final ResultInfo castInfo;
3041         JCExpression expr = TreeInfo.skipParens(tree.expr);
3042         boolean isPoly = expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE);
3043         if (isPoly) {




3003                 if (ctype != null) {
3004                     owntype = cfolder.coerce(ctype, owntype);
3005 
3006                     // Remove constant types from arguments to
3007                     // conserve space. The parser will fold concatenations
3008                     // of string literals; the code here also
3009                     // gets rid of intermediate results when some of the
3010                     // operands are constant identifiers.
3011                     if (tree.lhs.type.tsym == syms.stringType.tsym) {
3012                         tree.lhs.type = syms.stringType;
3013                     }
3014                     if (tree.rhs.type.tsym == syms.stringType.tsym) {
3015                         tree.rhs.type = syms.stringType;
3016                     }
3017                 }
3018             }
3019 
3020             // Check that argument types of a reference ==, != are
3021             // castable to each other, (JLS???).
3022             if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
3023                 if (!types.isEqualityComparable(left, right,
3024                                                 new Warner(tree.pos()))) {
3025                     log.error(tree.pos(), "incomparable.types", left, right);
3026                 }
3027             }
3028 
3029             chk.checkDivZero(tree.rhs.pos(), operator, right);
3030         }
3031         result = check(tree, owntype, VAL, resultInfo);
3032     }
3033 
3034     public void visitTypeCast(final JCTypeCast tree) {
3035         Type clazztype = attribType(tree.clazz, env);
3036         chk.validate(tree.clazz, env, false);
3037         //a fresh environment is required for 292 inference to work properly ---
3038         //see Infer.instantiatePolymorphicSignatureInstance()
3039         Env<AttrContext> localEnv = env.dup(tree);
3040         //should we propagate the target type?
3041         final ResultInfo castInfo;
3042         JCExpression expr = TreeInfo.skipParens(tree.expr);
3043         boolean isPoly = expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE);
3044         if (isPoly) {