Package com.redhat.ceylon.compiler.typechecker.model

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


                    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);
                }
                it.setSatisfiedTypes(types);
                td = it;
            } else {
                throw new IllegalArgumentException("Invalid composite type '" + m.get("comp") + "'");
            }
        } else if (td == null) {
View Full Code Here


            List<ProducedType> list = new ArrayList<ProducedType>();
            try {
                for (ProducedType st: d.getType().getSupertypes()) {
                    addToIntersection(list, st, unit);
                }
                IntersectionType it = new IntersectionType(unit);
                it.setSatisfiedTypes(list);
        it.canonicalize().getType();
            }
            catch (RuntimeException re) {
                if (displayErrors)
                that.addError("inheritance hierarchy is undecidable: " +
                        "could not canonicalize the intersection of all supertypes of '" +
View Full Code Here

            List<ProducedType> list =
                    new ArrayList<ProducedType>(upperBounds.size());
            for (ProducedType st: upperBounds) {
                addToIntersection(list, st, unit);
            }
            IntersectionType it = new IntersectionType(unit);
            it.setSatisfiedTypes(list);
            if (it.canonicalize().getType().isNothing()) {
                that.addError(typeDescription(td, unit) +
                        " has unsatisfiable upper bound constraints: the constraints '" +
                        typeNamesAsIntersection(upperBounds, unit) +
                        "' cannot be satisfied by any type except 'Nothing'");
            }
View Full Code Here

            //TODO: st.getProducedType(receiver, dec, typeArgs);
            if (!st.containsTypeParameters()) {
                addToIntersection(list, st, unit);
            }
        }
        IntersectionType it = new IntersectionType(unit);
        it.setSatisfiedTypes(list);
        ProducedType type = it.canonicalize().getType();
        return type;
    }
View Full Code Here

        ut.setCaseTypes(types);
        return ut.getType();
    }
   
    private ProducedType formIntersection(List<ProducedType> types) {
        IntersectionType it = new IntersectionType(unit);
        it.setSatisfiedTypes(types);
        return it.canonicalize().getType();
    }
View Full Code Here

        for (Tree.StaticType st: that.getStaticTypes()) {
            //addToIntersection(types, st.getTypeModel(), unit);
            ProducedType t = st.getTypeModel();
            if (t!=null) types.add(t);
        }
        IntersectionType it = new IntersectionType(unit);
        it.setSatisfiedTypes(types);
        that.setTypeModel(it.getType());
        //that.setTarget(pt);
    }
View Full Code Here

                if (t!=null) types.add(t);
            }
            ProducedType t = new LazyProducedType(unit) {
                @Override
                public TypeDeclaration initDeclaration() {
                    IntersectionType it = new IntersectionType(unit);
                    it.setSatisfiedTypes(types);
                    return it;
                }
                @Override
                public Map<TypeParameter, ProducedType> initTypeArguments() {
                    return emptyMap();
View Full Code Here

                    return true;
            }
            return false;
        }
        if(declaration instanceof IntersectionType){
            IntersectionType ut = (IntersectionType) declaration;
            java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
            for(ProducedType pt : satisfiedTypes){
                if(hasTypeParameterWithConstraintsOutsideScopeResolved(pt, scope))
                    return true;
            }
            return false;
View Full Code Here

    private ProducedType obtainTypeParameterBound(Module moduleScope, TypeMirror type, Scope scope, Set<TypeDeclaration> rawDeclarationsSeen) {
        // type variables are never mapped
        if(type.getKind() == TypeKind.TYPEVAR){
            TypeParameterMirror typeParameter = type.getTypeParameter();
            if(!typeParameter.getBounds().isEmpty()){
                IntersectionType it = new IntersectionType(getUnitForModule(moduleScope));
                for(TypeMirror bound : typeParameter.getBounds()){
                    ProducedType boundModel = obtainTypeParameterBound(moduleScope, bound, scope, rawDeclarationsSeen);
                    it.getSatisfiedTypes().add(boundModel);
                }
                return it.getType();
            }else
                // no bound is Object
                return typeFactory.getObjectDeclaration().getType();
        }else{
            TypeMirror mappedType = applyTypeMapping(type, TypeLocation.TYPE_PARAM);
View Full Code Here

            }
            // must be erased
            return true;
        }
        if(declaration instanceof IntersectionType){
            IntersectionType ut = (IntersectionType) declaration;
            java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
            // special case for non-optional types
            if(satisfiedTypes.size() == 2){
                if(isObject(satisfiedTypes.get(0)))
                    return hasErasureResolved(satisfiedTypes.get(1));
                if(isObject(satisfiedTypes.get(1)))
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.IntersectionType

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.