Search in sources :

Example 1 with TypeWithExpression

use of com.google.errorprone.refaster.UTypeVar.TypeWithExpression in project error-prone by google.

the class UTypeVarIdent method defaultAction.

@Override
protected Choice<Unifier> defaultAction(Tree target, Unifier unifier) {
    JCExpression expr = (JCExpression) target;
    Type targetType = expr.type;
    if (targetType == null) {
        return Choice.none();
    }
    @Nullable TypeWithExpression boundType = unifier.getBinding(key());
    if (boundType == null) {
        unifier.putBinding(key(), expr.accept(QUALIFIED_FROM_PACKAGE, null) ? TypeWithExpression.create(targetType) : /* use the ImportPolicy to refer to this type */
        TypeWithExpression.create(targetType, expr));
        return Choice.of(unifier);
    } else if (unifier.types().isSameType(targetType, boundType.type())) {
        return Choice.of(unifier);
    }
    return Choice.none();
}
Also used : Type(com.sun.tools.javac.code.Type) JCExpression(com.sun.tools.javac.tree.JCTree.JCExpression) TypeWithExpression(com.google.errorprone.refaster.UTypeVar.TypeWithExpression) Nullable(javax.annotation.Nullable)

Aggregations

TypeWithExpression (com.google.errorprone.refaster.UTypeVar.TypeWithExpression)1 Type (com.sun.tools.javac.code.Type)1 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)1 Nullable (javax.annotation.Nullable)1