Examples of UnionType


Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        if (td == null && m.containsKey("comp")) {
            @SuppressWarnings("unchecked")
            final List<Map<String,Object>> tmaps = (List<Map<String,Object>>)m.get(MetamodelGenerator.KEY_TYPES);
            final ArrayList<ProducedType> types = new ArrayList<ProducedType>(tmaps.size());
            if ("u".equals(m.get("comp"))) {
                UnionType ut = new UnionType(u2);
                for (Map<String, Object> tmap : tmaps) {
                    Util.addToUnion(types, getTypeFromJson(tmap, container, typeParams));
                }
                ut.setCaseTypes(types);
                td = ut;
            } else if ("i".equals(m.get("comp"))) {
                IntersectionType it = new IntersectionType(u2);
                for (Map<String, Object> tmap : tmaps) {
                    Util.addToIntersection(types, getTypeFromJson(tmap, container, typeParams), u2);
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

            if (et==null || et.isSubtypeOf(at)) {
                returnType.setTypeModel(at);
            }
            else {
                if (!at.isSubtypeOf(et)) {
                    UnionType ut = new UnionType(unit);
                    List<ProducedType> list =
                            new ArrayList<ProducedType>(2);
                    addToUnion(list, et);
                    addToUnion(list, at);
                    ut.setCaseTypes(list);
                    returnType.setTypeModel( ut.getType() );
                }
            }
        }
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        }
        return formIntersection(types);
    }

    private ProducedType formUnion(List<ProducedType> types) {
        UnionType ut = new UnionType(unit);
        ut.setCaseTypes(types);
        return ut.getType();
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        if (!isTypeUnknown(rhst) && !isTypeUnknown(lhst)) {
            checkOptional(lhst, that.getLeftTerm(), that.getLeftTerm());
            List<ProducedType> list = new ArrayList<ProducedType>(2);
            addToUnion(list, unit.denotableType(rhst));
            addToUnion(list, unit.getDefiniteType(unit.denotableType(lhst)));
            UnionType ut = new UnionType(unit);
            ut.setCaseTypes(list);
            ProducedType rt = ut.getType();
            that.setTypeModel(rt);
            /*that.setTypeModel(rhst);
            ProducedType ot;
            if (isOptionalType(rhst)) {
                ot = rhst;
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

                }
                else {
                    addToUnion(list, ct);
                }
            }
            UnionType ut = new UnionType(unit);
            ut.setCaseTypes(list);
            //if the union of the case types covers
            //the switch expression type then the
            //switch is exhaustive
            if (!ut.getType().covers(st)) {
                switchClause.addError("case types must cover all cases of the switch type or an else clause must appear: '" +
                                ut.getType().getProducedTypeName(unit) + "' does not cover '" +
                                st.getProducedTypeName(unit) + "'");
            }
        }
        /*else if (dynamic) {
            that.addError("else clause must appear: static type not known");
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

    }

    public static boolean abbreviateOptional(ProducedType pt) {
        if (pt.getDeclaration() instanceof UnionType) {
            Unit unit = pt.getDeclaration().getUnit();
            UnionType ut = (UnionType) pt.getDeclaration();
            return ut.getCaseTypes().size()==2 &&
                    isElementOfUnion(ut, unit.getNullDeclaration()); /*&&
                    minus(unit.getNullDeclaration()).isPrimitiveAbbreviatedType();*/
        }
        else {
            return false;
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

            elemtypes.set(lastIndex, u.getSequentialElementType(last));
        }
        if (elemtypes==null) {
            return false;
        }
        UnionType ut = new UnionType(u);
        ut.setCaseTypes(elemtypes);
        ProducedType t = ut.getType();
        ProducedType typeArg =
                args.getTypeArgumentList().get(0);
        if (typeArg==null) {
            return false;
        }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

                public TypeDeclaration initDeclaration() {
                    List<ProducedType> types =
                            new ArrayList<ProducedType>(2);
                    types.add(unit.getType(unit.getNullDeclaration()));
                    if (definiteType!=null) types.add(definiteType);
                    UnionType ut = new UnionType(unit);
                    ut.setCaseTypes(types);
                    return ut;
                }
                @Override
                public Map<TypeParameter, ProducedType> initTypeArguments() {
                    return emptyMap();
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        }
        if (inExtends) {
            ProducedType t = new LazyProducedType(unit) {
                @Override
                public TypeDeclaration initDeclaration() {
                    UnionType ut = new UnionType(unit);
                    ut.setCaseTypes(types);
                    return ut;
                }
                @Override
                public Map<TypeParameter, ProducedType> initTypeArguments() {
                    return emptyMap();
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        for (Tree.StaticType st: that.getStaticTypes()) {
            //addToUnion( types, st.getTypeModel() );
            ProducedType t = st.getTypeModel();
            if (t!=null) types.add(t);
        }
        UnionType ut = new UnionType(unit);
        ut.setCaseTypes(types);
        that.setTypeModel(ut.getType());
        //that.setTarget(pt);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.