@Override public void visitWildcard(JCWildcard tree) { if (tree.inner != null) validate(tree.inner); }
@Override public void visitWildcard(JCWildcard tree) { if (tree.inner != null) validate(tree.inner); }
public void visitTypeArray(JCArrayTypeTree tree) { validate(tree.elemtype); }
public void visitTypeArray(JCArrayTypeTree tree) { validate(tree.elemtype); }
/** Validate a type expression. That is, * check that all type arguments of a parametric type are within * their bounds. This must be done in a second phase after type attribution * since a class might have a subclass as type parameter bound. E.g: * * <pre>{@code * class B<A extends C> { ... } * class C extends B<C> { ... } * }</pre> * * and we can't make sure that the bound is already attributed because * of possible cycles. * * Visitor method: Validate a type expression, if it is not null, catching * and reporting any completion failures. */ void validate(JCTree tree, Env<AttrContext> env) { validate(tree, env, true); } void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) {
/** Validate a type expression. That is, * check that all type arguments of a parametric type are within * their bounds. This must be done in a second phase after type attribution * since a class might have a subclass as type parameter bound. E.g: * * <pre>{@code * class B<A extends C> { ... } * class C extends B<C> { ... } * }</pre> * * and we can't make sure that the bound is already attributed because * of possible cycles. * * Visitor method: Validate a type expression, if it is not null, catching * and reporting any completion failures. */ void validate(JCTree tree, Env<AttrContext> env) { validate(tree, env, true); } void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) {
/** Visitor method: Validate a list of type expressions. */ void validate(List<? extends JCTree> trees) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) validate(l.head); }
/** Visitor method: Validate a list of type expressions. */ void validate(List<? extends JCTree> trees, Env<AttrContext> env) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) validate(l.head, env); }
/** Visitor method: Validate a list of type expressions. */ void validate(List<? extends JCTree> trees) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) validate(l.head); }
/** Visitor method: Validate a list of type parameters. */ void validateTypeParams(List<JCTypeParameter> trees) { for (List<JCTypeParameter> l = trees; l.nonEmpty(); l = l.tail) validate(l.head); }
/** Visitor method: Validate a list of type parameters. */ void validateTypeParams(List<JCTypeParameter> trees) { for (List<JCTypeParameter> l = trees; l.nonEmpty(); l = l.tail) validate(l.head); }
/** Visitor method: Validate a list of type expressions. */ void validate(List<? extends JCTree> trees, Env<AttrContext> env) { for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail) validate(l.head, env); }
public void visitTypeParameter(JCTypeParameter tree) { validate(tree.bounds); checkClassBounds(tree.pos(), tree.type); }
public void visitTypeParameter(JCTypeParameter tree) { validate(tree.bounds); checkClassBounds(tree.pos(), tree.type); }
public void visitSelectInternal(JCFieldAccess tree) { if (tree.type.getEnclosingType().tag != CLASS && tree.selected.type.isParameterized()) { // The enclosing type is not a class, so we are // looking at a static member type. However, the // qualifying expression is parameterized. log.error(tree.pos(), "cant.select.static.class.from.param.type"); } else { // otherwise validate the rest of the expression validate(tree.selected); } }
public void visitSelectInternal(JCFieldAccess tree) { if (tree.type.getEnclosingType().tag != CLASS && tree.selected.type.isParameterized()) { // The enclosing type is not a class, so we are // looking at a static member type. However, the // qualifying expression is parameterized. log.error(tree.pos(), "cant.select.static.class.from.param.type"); } else { // otherwise validate the rest of the expression validate(tree.selected); } }
public void visitTypeTest(JCInstanceOf tree) { Type exprtype = chk.checkNullOrRefType( tree.expr.pos(), attribExpr(tree.expr, env)); Type clazztype = attribType(tree.clazz, env); if (!clazztype.hasTag(TYPEVAR)) { clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype); } if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) { log.error(tree.clazz.pos(), "illegal.generic.type.for.instof"); clazztype = types.createErrorType(clazztype); } chk.validate(tree.clazz, env, false); chk.checkCastable(tree.expr.pos(), exprtype, clazztype); result = check(tree, syms.booleanType, VAL, resultInfo); }
public void visitTypeTest(JCInstanceOf tree) { Type exprtype = chk.checkNullOrRefType( tree.expr.pos(), attribExpr(tree.expr, env)); Type clazztype = attribType(tree.clazz, env); if (!clazztype.hasTag(TYPEVAR)) { clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype); } if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) { log.error(tree.clazz.pos(), "illegal.generic.type.for.instof"); clazztype = types.createErrorType(clazztype); } chk.validate(tree.clazz, env, false); chk.checkCastable(tree.expr.pos(), exprtype, clazztype); result = check(tree, syms.booleanType, VAL, resultInfo); }
public void visitTypeCast(final JCTypeCast tree) { Type clazztype = attribType(tree.clazz, env); chk.validate(tree.clazz, env, false); //a fresh environment is required for 292 inference to work properly --- //see Infer.instantiatePolymorphicSignatureInstance() Env<AttrContext> localEnv = env.dup(tree); //should we propagate the target type? final ResultInfo castInfo; JCExpression expr = TreeInfo.skipParens(tree.expr); boolean isPoly = allowPoly && (expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE)); if (isPoly) { //expression is a poly - we need to propagate target type info castInfo = new ResultInfo(VAL, clazztype, new Check.NestedCheckContext(resultInfo.checkContext) { @Override public boolean compatible(Type found, Type req, Warner warn) { return types.isCastable(found, req, warn); } }); } else { //standalone cast - target-type info is not propagated castInfo = unknownExprInfo; } Type exprtype = attribTree(tree.expr, localEnv, castInfo); Type owntype = isPoly ? clazztype : chk.checkCastable(tree.expr.pos(), exprtype, clazztype); if (exprtype.constValue() != null) owntype = cfolder.coerce(exprtype, owntype); result = check(tree, capture(owntype), VAL, resultInfo); if (!isPoly) chk.checkRedundantCast(localEnv, tree); }
if (tree.elemtype != null) { elemtype = attribType(tree.elemtype, localEnv); chk.validate(tree.elemtype, localEnv); owntype = elemtype; for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {