Package com.sun.tools.javac.code

Examples of com.sun.tools.javac.code.Type


        names = Names.instance(context);
        target = Target.instance(context);

        // Create the unknown type
        unknownType = new Type(TypeTags.UNKNOWN, null) {
            @Override
            public <R, P> R accept(TypeVisitor<R, P> v, P p) {
                return v.visitUnknown(this, p);
            }
        };
View Full Code Here


            // VGJ: sort of inlined maximizeInst() below.  Adding
            // bounds can cause lobounds that are above hibounds.
            List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
            if (hibounds.isEmpty())
                return;
            Type hb = null;
            if (hibounds.tail.isEmpty())
                hb = hibounds.head;
            else for (List<Type> bs = hibounds;
                      bs.nonEmpty() && hb == null;
                      bs = bs.tail) {
View Full Code Here

            if (inst.nonEmpty() && inst.head.tag != BOT) {
                uv.inst = inst.head;
            }
            uv.hibounds = hibounds.toList();
        }
        Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
        if (!types.isSubtype(qtype1,
                qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
            throw unambiguousNoInstanceException
                .setMessage("infer.no.conforming.instance.exists",
                            that.tvars, that.qtype, to);
View Full Code Here

    private List<Type> instaniateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
        ListBuffer<Type> new_targs = ListBuffer.lb();
        //step 1 - create syntethic captured vars
        for (Type t : undetvars) {
            UndetVar uv = (UndetVar)t;
            Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
            new_targs = new_targs.append(newArg);
        }
        //step 2 - replace synthetic vars in their bounds
        for (Type t : new_targs.toList()) {
            CapturedType ct = (CapturedType)t;
View Full Code Here

        final List<Type> capturedArgs = types.capture(argtypes);
        List<Type> actuals = capturedArgs;
        List<Type> actualsNoCapture = argtypes;
        // instantiate all polymorphic argument types and
        // set up lower bounds constraints for undetvars
        Type varargsFormal = useVarargs ? formals.last() : null;
        if (varargsFormal == null &&
                actuals.size() != formals.size()) {
            throw unambiguousNoInstanceException
                .setMessage("infer.arg.length.mismatch");
        }
        while (actuals.nonEmpty() && formals.head != varargsFormal) {
            Type formal = formals.head;
            Type actual = actuals.head.baseType();
            Type actualNoCapture = actualsNoCapture.head.baseType();
            if (actual.tag == FORALL)
                actual = instantiateArg((ForAll)actual, formal, tvars, warn);
            Type undetFormal = types.subst(formal, tvars, undetvars);
            boolean works = allowBoxing
                ? types.isConvertible(actual, undetFormal, warn)
                : types.isSubtypeUnchecked(actual, undetFormal, warn);
            if (!works) {
                throw unambiguousNoInstanceException
                    .setMessage("infer.no.conforming.assignment.exists",
                                tvars, actualNoCapture, formal);
            }
            formals = formals.tail;
            actuals = actuals.tail;
            actualsNoCapture = actualsNoCapture.tail;
        }

        if (formals.head != varargsFormal) // not enough args
            throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");

        // for varargs arguments as well
        if (useVarargs) {
            Type elemType = types.elemtype(varargsFormal);
            Type elemUndet = types.subst(elemType, tvars, undetvars);
            while (actuals.nonEmpty()) {
                Type actual = actuals.head.baseType();
                Type actualNoCapture = actualsNoCapture.head.baseType();
                if (actual.tag == FORALL)
                    actual = instantiateArg((ForAll)actual, elemType, tvars, warn);
                boolean works = types.isConvertible(actual, elemUndet, warn);
                if (!works) {
                    throw unambiguousNoInstanceException
View Full Code Here

                                Warner warn) throws InferenceException {
        List<Type> targs;
        try {
            return instantiateExpr(that, to, warn);
        } catch (NoInstanceException ex) {
            Type to1 = to;
            for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
                to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
            return instantiateExpr(that, to1, warn);
        }
    }
View Full Code Here

     */
    Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site,
                                            Name name,
                                            MethodSymbol spMethod,  // sig. poly. method or null if none
                                            List<Type> argtypes) {
        final Type restype;

        //The return type for a polymorphic signature call is computed from
        //the enclosing tree E, as follows: if E is a cast, then use the
        //target type of the cast expression as a return type; if E is an
        //expression statement, the return type is 'void' - otherwise the
View Full Code Here

                public UninferredReturnType(List<Type> tvars, Type restype) {
                    super(tvars, restype);
                }
                @Override
                public Type inst(List<Type> actuals, Types types) {
                    Type newRestype = super.inst(actuals, types);
                    instantiateReturnType(newRestype, actuals, types);
                    return newRestype;
                }
View Full Code Here

            UndetVar uv = (UndetVar)s;
            if (uv.inst != null)
                return isSubtypeUnchecked(t, uv.inst, warn);
        }
        else if (!s.isRaw()) {
            Type t2 = asSuper(t, s.tsym);
            if (t2 != null && t2.isRaw()) {
                if (isReifiable(s))
                    warn.silentWarn(LintCategory.UNCHECKED);
                else
                    warn.warn(LintCategory.UNCHECKED);
                return true;
View Full Code Here

                    return false;
            }
            return true;
        }

        Type lower = lowerBound(s);
        if (s != lower)
            return isSubtype(capture ? capture(t) : t, lower, false);

        return isSubtype.visit(capture ? capture(t) : t, s);
    }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.code.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.