612 for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { |
612 for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { |
613 attribStat(l.head, localEnv); |
613 attribStat(l.head, localEnv); |
614 } |
614 } |
615 |
615 |
616 // Check that type parameters are well-formed. |
616 // Check that type parameters are well-formed. |
617 chk.validateTypeParams(tree.typarams); |
617 chk.validate(tree.typarams, localEnv); |
618 if ((owner.flags() & ANNOTATION) != 0 && |
618 if ((owner.flags() & ANNOTATION) != 0 && |
619 tree.typarams.nonEmpty()) |
619 tree.typarams.nonEmpty()) |
620 log.error(tree.typarams.head.pos(), |
620 log.error(tree.typarams.head.pos(), |
621 "intf.annotation.members.cant.have.type.params"); |
621 "intf.annotation.members.cant.have.type.params"); |
622 |
622 |
623 // Check that result type is well-formed. |
623 // Check that result type is well-formed. |
624 chk.validate(tree.restype); |
624 chk.validate(tree.restype, localEnv); |
625 if ((owner.flags() & ANNOTATION) != 0) |
625 if ((owner.flags() & ANNOTATION) != 0) |
626 chk.validateAnnotationType(tree.restype); |
626 chk.validateAnnotationType(tree.restype); |
627 |
627 |
628 if ((owner.flags() & ANNOTATION) != 0) |
628 if ((owner.flags() & ANNOTATION) != 0) |
629 chk.validateAnnotationMethod(tree.pos(), m); |
629 chk.validateAnnotationMethod(tree.pos(), m); |
705 annotate.flush(); |
705 annotate.flush(); |
706 } |
706 } |
707 } |
707 } |
708 |
708 |
709 // Check that the variable's declared type is well-formed. |
709 // Check that the variable's declared type is well-formed. |
710 chk.validate(tree.vartype); |
710 chk.validate(tree.vartype, env); |
711 |
711 |
712 VarSymbol v = tree.sym; |
712 VarSymbol v = tree.sym; |
713 Lint lint = env.info.lint.augment(v.attributes_field, v.flags()); |
713 Lint lint = env.info.lint.augment(v.attributes_field, v.flags()); |
714 Lint prevLint = chk.setLint(lint); |
714 Lint prevLint = chk.setLint(lint); |
715 |
715 |
1320 |
1320 |
1321 // Check that value of resulting type is admissible in the |
1321 // Check that value of resulting type is admissible in the |
1322 // current context. Also, capture the return type |
1322 // current context. Also, capture the return type |
1323 result = check(tree, capture(restype), VAL, pkind, pt); |
1323 result = check(tree, capture(restype), VAL, pkind, pt); |
1324 } |
1324 } |
1325 chk.validate(tree.typeargs); |
1325 chk.validate(tree.typeargs, localEnv); |
1326 } |
1326 } |
1327 //where |
1327 //where |
1328 /** Check that given application node appears as first statement |
1328 /** Check that given application node appears as first statement |
1329 * in a constructor call. |
1329 * in a constructor call. |
1330 * @param tree The application node |
1330 * @param tree The application node |
1395 |
1395 |
1396 // Attribute clazz expression and store |
1396 // Attribute clazz expression and store |
1397 // symbol + type back into the attributed tree. |
1397 // symbol + type back into the attributed tree. |
1398 Type clazztype = chk.checkClassType( |
1398 Type clazztype = chk.checkClassType( |
1399 tree.clazz.pos(), attribType(clazz, env), true); |
1399 tree.clazz.pos(), attribType(clazz, env), true); |
1400 chk.validate(clazz); |
1400 chk.validate(clazz, localEnv); |
1401 if (tree.encl != null) { |
1401 if (tree.encl != null) { |
1402 // We have to work in this case to store |
1402 // We have to work in this case to store |
1403 // symbol + type back into the attributed tree. |
1403 // symbol + type back into the attributed tree. |
1404 tree.clazz.type = clazztype; |
1404 tree.clazz.type = clazztype; |
1405 TreeInfo.setSymbol(clazzid, TreeInfo.symbol(clazzid1)); |
1405 TreeInfo.setSymbol(clazzid, TreeInfo.symbol(clazzid1)); |
1531 |
1531 |
1532 if (tree.constructor != null && tree.constructor.kind == MTH) |
1532 if (tree.constructor != null && tree.constructor.kind == MTH) |
1533 owntype = clazztype; |
1533 owntype = clazztype; |
1534 } |
1534 } |
1535 result = check(tree, owntype, VAL, pkind, pt); |
1535 result = check(tree, owntype, VAL, pkind, pt); |
1536 chk.validate(tree.typeargs); |
1536 chk.validate(tree.typeargs, localEnv); |
1537 } |
1537 } |
1538 |
1538 |
1539 /** Make an attributed null check tree. |
1539 /** Make an attributed null check tree. |
1540 */ |
1540 */ |
1541 public JCExpression makeNullCheck(JCExpression arg) { |
1541 public JCExpression makeNullCheck(JCExpression arg) { |
1553 public void visitNewArray(JCNewArray tree) { |
1553 public void visitNewArray(JCNewArray tree) { |
1554 Type owntype = types.createErrorType(tree.type); |
1554 Type owntype = types.createErrorType(tree.type); |
1555 Type elemtype; |
1555 Type elemtype; |
1556 if (tree.elemtype != null) { |
1556 if (tree.elemtype != null) { |
1557 elemtype = attribType(tree.elemtype, env); |
1557 elemtype = attribType(tree.elemtype, env); |
1558 chk.validate(tree.elemtype); |
1558 chk.validate(tree.elemtype, env); |
1559 owntype = elemtype; |
1559 owntype = elemtype; |
1560 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) { |
1560 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) { |
1561 attribExpr(l.head, env, syms.intType); |
1561 attribExpr(l.head, env, syms.intType); |
1562 owntype = new ArrayType(owntype, syms.arrayClass); |
1562 owntype = new ArrayType(owntype, syms.arrayClass); |
1563 } |
1563 } |
1709 result = check(tree, owntype, VAL, pkind, pt); |
1709 result = check(tree, owntype, VAL, pkind, pt); |
1710 } |
1710 } |
1711 |
1711 |
1712 public void visitTypeCast(JCTypeCast tree) { |
1712 public void visitTypeCast(JCTypeCast tree) { |
1713 Type clazztype = attribType(tree.clazz, env); |
1713 Type clazztype = attribType(tree.clazz, env); |
|
1714 chk.validate(tree.clazz, env); |
1714 Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly); |
1715 Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly); |
1715 Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
1716 Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
1716 if (exprtype.constValue() != null) |
1717 if (exprtype.constValue() != null) |
1717 owntype = cfolder.coerce(exprtype, owntype); |
1718 owntype = cfolder.coerce(exprtype, owntype); |
1718 result = check(tree, capture(owntype), VAL, pkind, pt); |
1719 result = check(tree, capture(owntype), VAL, pkind, pt); |
1721 public void visitTypeTest(JCInstanceOf tree) { |
1722 public void visitTypeTest(JCInstanceOf tree) { |
1722 Type exprtype = chk.checkNullOrRefType( |
1723 Type exprtype = chk.checkNullOrRefType( |
1723 tree.expr.pos(), attribExpr(tree.expr, env)); |
1724 tree.expr.pos(), attribExpr(tree.expr, env)); |
1724 Type clazztype = chk.checkReifiableReferenceType( |
1725 Type clazztype = chk.checkReifiableReferenceType( |
1725 tree.clazz.pos(), attribType(tree.clazz, env)); |
1726 tree.clazz.pos(), attribType(tree.clazz, env)); |
|
1727 chk.validate(tree.clazz, env); |
1726 chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
1728 chk.checkCastable(tree.expr.pos(), exprtype, clazztype); |
1727 result = check(tree, syms.booleanType, VAL, pkind, pt); |
1729 result = check(tree, syms.booleanType, VAL, pkind, pt); |
1728 } |
1730 } |
1729 |
1731 |
1730 public void visitIndexed(JCArrayAccess tree) { |
1732 public void visitIndexed(JCArrayAccess tree) { |
2693 // Validate annotations |
2695 // Validate annotations |
2694 chk.validateAnnotations(tree.mods.annotations, c); |
2696 chk.validateAnnotations(tree.mods.annotations, c); |
2695 |
2697 |
2696 // Validate type parameters, supertype and interfaces. |
2698 // Validate type parameters, supertype and interfaces. |
2697 attribBounds(tree.typarams); |
2699 attribBounds(tree.typarams); |
2698 chk.validateTypeParams(tree.typarams); |
2700 chk.validate(tree.typarams, env); |
2699 chk.validate(tree.extending); |
2701 chk.validate(tree.extending, env); |
2700 chk.validate(tree.implementing); |
2702 chk.validate(tree.implementing, env); |
2701 |
2703 |
2702 // If this is a non-abstract class, check that it has no abstract |
2704 // If this is a non-abstract class, check that it has no abstract |
2703 // methods or unimplemented methods of an implemented interface. |
2705 // methods or unimplemented methods of an implemented interface. |
2704 if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) { |
2706 if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) { |
2705 if (!relax) |
2707 if (!relax) |