Java Code Examples for com.sun.tools.javac.code.Type#getOriginalType()

The following examples show how to use com.sun.tools.javac.code.Type#getOriginalType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Annotate.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Attribute getAnnotationClassValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
    Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType));
    if (result.isErroneous()) {
        // Does it look like an unresolved class literal?
        if (TreeInfo.name(tree) == names._class &&
                ((JCFieldAccess) tree).selected.type.isErroneous()) {
            Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName();
            return new Attribute.UnresolvedClass(expectedElementType,
                    types.createErrorType(n,
                            syms.unknownSymbol, syms.classType));
        } else {
            return new Attribute.Error(result.getOriginalType());
        }
    }

    // Class literals look like field accesses of a field named class
    // at the tree level
    if (TreeInfo.name(tree) != names._class) {
        log.error(tree.pos(), Errors.AnnotationValueMustBeClassLiteral);
        return new Attribute.Error(syms.errType);
    }

    return new Attribute.Class(types,
            (((JCFieldAccess) tree).selected).type);
}
 
Example 2
Source File: Annotate.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Attribute getAnnotationEnumValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
    Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType));
    Symbol sym = TreeInfo.symbol(tree);
    if (sym == null ||
            TreeInfo.nonstaticSelect(tree) ||
            sym.kind != VAR ||
            (sym.flags() & Flags.ENUM) == 0) {
        log.error(tree.pos(), Errors.EnumAnnotationMustBeEnumConstant);
        return new Attribute.Error(result.getOriginalType());
    }
    VarSymbol enumerator = (VarSymbol) sym;
    return new Attribute.Enum(expectedElementType, enumerator);
}
 
Example 3
Source File: Annotate.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Attribute getAnnotationPrimitiveValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
    Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType));
    if (result.isErroneous())
        return new Attribute.Error(result.getOriginalType());
    if (result.constValue() == null) {
        log.error(tree.pos(), Errors.AttributeValueMustBeConstant);
        return new Attribute.Error(expectedElementType);
    }
    result = cfolder.coerce(result, expectedElementType);
    return new Attribute.Constant(expectedElementType, result.constValue());
}
 
Example 4
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void doImport(JCImport tree) {
    JCFieldAccess imp = (JCFieldAccess)tree.qualid;
    Name name = TreeInfo.name(imp);

    // Create a local environment pointing to this tree to disable
    // effects of other imports in Resolve.findGlobalType
    Env<AttrContext> localEnv = env.dup(tree);

    TypeSymbol p = attr.attribImportQualifier(tree, localEnv).tsym;
    if (name == names.asterisk) {
        // Import on demand.
        chk.checkCanonical(imp.selected);
        if (tree.staticImport)
            importStaticAll(tree, p, env);
        else
            importAll(tree, p, env);
    } else {
        // Named type import.
        if (tree.staticImport) {
            importNamedStatic(tree, p, name, localEnv);
            chk.checkCanonical(imp.selected);
        } else {
            Type importedType = attribImportType(imp, localEnv);
            Type originalType = importedType.getOriginalType();
            TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym;
            chk.checkCanonical(imp);
            importNamed(tree.pos(), c, env, tree);
        }
    }
}
 
Example 5
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected Type modelMissingTypes(Env<AttrContext> env, Type t, final JCExpression tree, final boolean interfaceExpected) {
    if (!t.hasTag(ERROR))
        return t;

    return new ErrorType(t.getOriginalType(), t.tsym) {
        private Type modelType;

        @Override
        public Type getModelType() {
            if (modelType == null)
                modelType = new Synthesizer(env.toplevel.modle, getOriginalType(), interfaceExpected).visit(tree);
            return modelType;
        }
    };
}