1183 chk.checkEmptyIf(tree); |
1183 chk.checkEmptyIf(tree); |
1184 result = null; |
1184 result = null; |
1185 } |
1185 } |
1186 |
1186 |
1187 public void visitExec(JCExpressionStatement tree) { |
1187 public void visitExec(JCExpressionStatement tree) { |
1188 attribExpr(tree.expr, env); |
1188 //a fresh environment is required for 292 inference to work properly --- |
|
1189 //see Infer.instantiatePolymorphicSignatureInstance() |
|
1190 Env<AttrContext> localEnv = env.dup(tree); |
|
1191 attribExpr(tree.expr, localEnv); |
1189 result = null; |
1192 result = null; |
1190 } |
1193 } |
1191 |
1194 |
1192 public void visitBreak(JCBreak tree) { |
1195 public void visitBreak(JCBreak tree) { |
1193 tree.target = findJumpTarget(tree.pos(), tree.getTag(), tree.label, env); |
1196 tree.target = findJumpTarget(tree.pos(), tree.getTag(), tree.label, env); |
1441 BoundKind.EXTENDS, |
1444 BoundKind.EXTENDS, |
1442 syms.boundClass)), |
1445 syms.boundClass)), |
1443 restype.tsym); |
1446 restype.tsym); |
1444 } |
1447 } |
1445 |
1448 |
1446 // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc) |
1449 // Special case logic for JSR 292 types. |
1447 // has type <T>, and T can be a primitive type. |
1450 if (rs.allowTransitionalJSR292 && |
1448 if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) { |
1451 tree.meth.getTag() == JCTree.SELECT && |
1449 JCFieldAccess mfield = (JCFieldAccess) tree.meth; |
1452 !typeargtypes.isEmpty()) { |
1450 if ((mfield.selected.type.tsym != null && |
1453 JCFieldAccess mfield = (JCFieldAccess) tree.meth; |
1451 (mfield.selected.type.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0) |
1454 // MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc) |
1452 || |
1455 // has type <T>, and T can be a primitive type. |
1453 (mfield.sym != null && |
1456 if (mfield.sym != null && |
1454 (mfield.sym.flags() & POLYMORPHIC_SIGNATURE) != 0)) { |
1457 mfield.sym.isPolymorphicSignatureInstance()) |
1455 assert types.isSameType(restype, typeargtypes.head) : mtype; |
1458 typeargtypesNonRefOK = true; |
1456 assert mfield.selected.type == syms.methodHandleType |
1459 } |
1457 || mfield.selected.type == syms.invokeDynamicType; |
1460 |
1458 typeargtypesNonRefOK = true; |
1461 if (!(rs.allowTransitionalJSR292 && typeargtypesNonRefOK)) { |
1459 } |
|
1460 } |
|
1461 |
|
1462 if (!typeargtypesNonRefOK) { |
|
1463 chk.checkRefTypes(tree.typeargs, typeargtypes); |
1462 chk.checkRefTypes(tree.typeargs, typeargtypes); |
1464 } |
1463 } |
1465 |
1464 |
1466 // Check that value of resulting type is admissible in the |
1465 // Check that value of resulting type is admissible in the |
1467 // current context. Also, capture the return type |
1466 // current context. Also, capture the return type |
2021 } |
2020 } |
2022 |
2021 |
2023 public void visitTypeCast(JCTypeCast tree) { |
2022 public void visitTypeCast(JCTypeCast tree) { |
2024 Type clazztype = attribType(tree.clazz, env); |
2023 Type clazztype = attribType(tree.clazz, env); |
2025 chk.validate(tree.clazz, env, false); |
2024 chk.validate(tree.clazz, env, false); |
2026 Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly); |
2025 //a fresh environment is required for 292 inference to work properly --- |
|
2026 //see Infer.instantiatePolymorphicSignatureInstance() |
|
2027 Env<AttrContext> localEnv = env.dup(tree); |
|
2028 Type exprtype = attribExpr(tree.expr, localEnv, Infer.anyPoly); |
2027 Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
2029 Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
2028 if (exprtype.constValue() != null) |
2030 if (exprtype.constValue() != null) |
2029 owntype = cfolder.coerce(exprtype, owntype); |
2031 owntype = cfolder.coerce(exprtype, owntype); |
2030 result = check(tree, capture(owntype), VAL, pkind, pt); |
2032 result = check(tree, capture(owntype), VAL, pkind, pt); |
2031 } |
2033 } |