Search in sources :

Example 6 with TypeVar

use of com.sun.tools.javac.code.Type.TypeVar in project error-prone by google.

the class Inliner method inlineAsVar.

public TypeVar inlineAsVar(UTypeVar var) throws CouldNotResolveImportException {
    /*
     * In order to handle recursively bounded type variables without a stack overflow,
     * we first cache a type var with no bounds, then we inline the bounds.
     */
    TypeVar typeVar = typeVarCache.get(var.getName());
    if (typeVar != null) {
        return typeVar;
    }
    Name name = asName(var.getName());
    TypeSymbol sym = new TypeVariableSymbol(0, name, null, symtab().noSymbol);
    typeVar = new TypeVar(sym, null, null);
    sym.type = typeVar;
    typeVarCache.put(var.getName(), typeVar);
    // Any recursive uses of var will point to the same TypeVar object generated above.
    typeVar.bound = var.getUpperBound().inline(this);
    typeVar.lower = var.getLowerBound().inline(this);
    return typeVar;
}
Also used : TypeVar(com.sun.tools.javac.code.Type.TypeVar) TypeSymbol(com.sun.tools.javac.code.Symbol.TypeSymbol) TypeVariableSymbol(com.sun.tools.javac.code.Symbol.TypeVariableSymbol) Name(com.sun.tools.javac.util.Name)

Aggregations

TypeVar (com.sun.tools.javac.code.Type.TypeVar)6 Type (com.sun.tools.javac.code.Type)4 ArrayType (com.sun.tools.javac.code.Type.ArrayType)3 ClassType (com.sun.tools.javac.code.Type.ClassType)3 MethodType (com.sun.tools.javac.code.Type.MethodType)2 UnionClassType (com.sun.tools.javac.code.Type.UnionClassType)2 WildcardType (com.sun.tools.javac.code.Type.WildcardType)2 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)2 VisitorState (com.google.errorprone.VisitorState)1 CompilerBasedAbstractTest (com.google.errorprone.matchers.CompilerBasedAbstractTest)1 MethodInvocationTree (com.sun.source.tree.MethodInvocationTree)1 ClassSymbol (com.sun.tools.javac.code.Symbol.ClassSymbol)1 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)1 TypeSymbol (com.sun.tools.javac.code.Symbol.TypeSymbol)1 TypeVariableSymbol (com.sun.tools.javac.code.Symbol.TypeVariableSymbol)1 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)1 JCClassDecl (com.sun.tools.javac.tree.JCTree.JCClassDecl)1 JCTypeParameter (com.sun.tools.javac.tree.JCTree.JCTypeParameter)1 Name (com.sun.tools.javac.util.Name)1 HashSet (java.util.HashSet)1